xzyang / rpms / libxml2

Forked from rpms/libxml2 3 years ago
Clone

Blame SOURCES/libxml2-Reuse-xmlHaltParser-where-it-makes-sense.patch

6dedca
From 586849318286965d6ede2932ccd31176b4f7fe81 Mon Sep 17 00:00:00 2001
6dedca
From: Daniel Veillard <veillard@redhat.com>
6dedca
Date: Fri, 20 Nov 2015 14:59:30 +0800
6dedca
Subject: [PATCH] Reuse xmlHaltParser() where it makes sense
6dedca
To: libvir-list@redhat.com
6dedca
6dedca
Unify the various place where either xmlStopParser was called
6dedca
(which resets the error as a side effect) and places where we
6dedca
used ctxt->instate = XML_PARSER_EOF to stop further processing
6dedca
6dedca
Signed-off-by: Daniel Veillard <veillard@redhat.com>
6dedca
---
6dedca
 parser.c | 37 +++++++++++++++++--------------------
6dedca
 1 file changed, 17 insertions(+), 20 deletions(-)
6dedca
6dedca
diff --git a/parser.c b/parser.c
6dedca
index 5b4f719..9aed98d 100644
6dedca
--- a/parser.c
6dedca
+++ b/parser.c
6dedca
@@ -1773,7 +1773,7 @@ nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
6dedca
 	xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
6dedca
 		 "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
6dedca
 			  xmlParserMaxDepth);
6dedca
-	ctxt->instate = XML_PARSER_EOF;
6dedca
+	xmlHaltParser(ctxt);
6dedca
 	return(-1);
6dedca
     }
6dedca
     ctxt->nodeTab[ctxt->nodeNr] = value;
6dedca
@@ -5655,7 +5655,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
6dedca
 	if (RAW != '>') {
6dedca
 	    xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
6dedca
 	            "xmlParseEntityDecl: entity %s not terminated\n", name);
6dedca
-	    xmlStopParser(ctxt);
6dedca
+	    xmlHaltParser(ctxt);
6dedca
 	} else {
6dedca
 	    if (input != ctxt->input) {
6dedca
 		xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6dedca
@@ -6767,8 +6767,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
6dedca
 	SKIP_BLANKS;
6dedca
 	if (RAW != '[') {
6dedca
 	    xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
6dedca
-	    xmlStopParser(ctxt);
6dedca
-	    ctxt->errNo = XML_ERR_CONDSEC_INVALID;
6dedca
+	    xmlHaltParser(ctxt);
6dedca
 	    return;
6dedca
 	} else {
6dedca
 	    if (ctxt->input->id != id) {
6dedca
@@ -6830,8 +6829,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
6dedca
 	SKIP_BLANKS;
6dedca
 	if (RAW != '[') {
6dedca
 	    xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
6dedca
-	    xmlStopParser(ctxt);
6dedca
-	    ctxt->errNo = XML_ERR_CONDSEC_INVALID;
6dedca
+	    xmlHaltParser(ctxt);
6dedca
 	    return;
6dedca
 	} else {
6dedca
 	    if (ctxt->input->id != id) {
6dedca
@@ -6888,8 +6886,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
6dedca
 
6dedca
     } else {
6dedca
 	xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID_KEYWORD, NULL);
6dedca
-	xmlStopParser(ctxt);
6dedca
-	ctxt->errNo = XML_ERR_CONDSEC_INVALID_KEYWORD;
6dedca
+	xmlHaltParser(ctxt);
6dedca
 	return;
6dedca
     }
6dedca
 
6dedca
@@ -7100,7 +7097,7 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
6dedca
 	    /*
6dedca
 	     * The XML REC instructs us to stop parsing right here
6dedca
 	     */
6dedca
-	    ctxt->instate = XML_PARSER_EOF;
6dedca
+	    xmlHaltParser(ctxt);
6dedca
 	    return;
6dedca
 	}
6dedca
     }
6dedca
@@ -8087,7 +8084,7 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
6dedca
 		     * The XML REC instructs us to stop parsing
6dedca
 		     * right here
6dedca
 		     */
6dedca
-		    ctxt->instate = XML_PARSER_EOF;
6dedca
+		    xmlHaltParser(ctxt);
6dedca
 		    return;
6dedca
 		}
6dedca
 	    }
6dedca
@@ -9986,7 +9983,7 @@ xmlParseContent(xmlParserCtxtPtr ctxt) {
6dedca
 	if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
6dedca
 	    xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
6dedca
 	                "detected an error in element content\n");
6dedca
-	    ctxt->instate = XML_PARSER_EOF;
6dedca
+	    xmlHaltParser(ctxt);
6dedca
             break;
6dedca
 	}
6dedca
     }
6dedca
@@ -10021,7 +10018,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
6dedca
 	xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
6dedca
 		 "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
6dedca
 			  xmlParserMaxDepth);
6dedca
-	ctxt->instate = XML_PARSER_EOF;
6dedca
+	xmlHaltParser(ctxt);
6dedca
 	return;
6dedca
     }
6dedca
 
6dedca
@@ -11345,7 +11342,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
6dedca
 			ctxt->sax->setDocumentLocator(ctxt->userData,
6dedca
 						      &xmlDefaultSAXLocator);
6dedca
 		    xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
6dedca
-		    ctxt->instate = XML_PARSER_EOF;
6dedca
+		    xmlHaltParser(ctxt);
6dedca
 #ifdef DEBUG_PUSH
6dedca
 		    xmlGenericError(xmlGenericErrorContext,
6dedca
 			    "PP: entering EOF\n");
6dedca
@@ -11378,7 +11375,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
6dedca
 			     * The XML REC instructs us to stop parsing right
6dedca
 			     * here
6dedca
 			     */
6dedca
-			    ctxt->instate = XML_PARSER_EOF;
6dedca
+			    xmlHaltParser(ctxt);
6dedca
 			    return(0);
6dedca
 			}
6dedca
 			ctxt->standalone = ctxt->input->standalone;
6dedca
@@ -11434,7 +11431,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
6dedca
 		cur = ctxt->input->cur[0];
6dedca
 	        if (cur != '<') {
6dedca
 		    xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
6dedca
-		    ctxt->instate = XML_PARSER_EOF;
6dedca
+		    xmlHaltParser(ctxt);
6dedca
 		    if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
6dedca
 			ctxt->sax->endDocument(ctxt->userData);
6dedca
 		    goto done;
6dedca
@@ -11466,7 +11463,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
6dedca
 		    goto done;
6dedca
 		if (name == NULL) {
6dedca
 		    spacePop(ctxt);
6dedca
-		    ctxt->instate = XML_PARSER_EOF;
6dedca
+		    xmlHaltParser(ctxt);
6dedca
 		    if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
6dedca
 			ctxt->sax->endDocument(ctxt->userData);
6dedca
 		    goto done;
6dedca
@@ -11633,7 +11630,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
6dedca
 		if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
6dedca
 		    xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
6dedca
 		                "detected an error in element content\n");
6dedca
-		    ctxt->instate = XML_PARSER_EOF;
6dedca
+		    xmlHaltParser(ctxt);
6dedca
 		    break;
6dedca
 		}
6dedca
 		break;
6dedca
@@ -11954,7 +11951,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
6dedca
 		    goto done;
6dedca
 		} else {
6dedca
 		    xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
6dedca
-		    ctxt->instate = XML_PARSER_EOF;
6dedca
+		    xmlHaltParser(ctxt);
6dedca
 #ifdef DEBUG_PUSH
6dedca
 		    xmlGenericError(xmlGenericErrorContext,
6dedca
 			    "PP: entering EOF\n");
6dedca
@@ -12318,7 +12315,7 @@ xmldecl_done:
6dedca
 	res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
6dedca
 	if (res < 0) {
6dedca
 	    ctxt->errNo = XML_PARSER_EOF;
6dedca
-	    ctxt->disableSAX = 1;
6dedca
+	    xmlHaltParser(ctxt);
6dedca
 	    return (XML_PARSER_EOF);
6dedca
 	}
6dedca
         xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
6dedca
@@ -12372,7 +12369,7 @@ xmldecl_done:
6dedca
          ((ctxt->input->cur - ctxt->input->base) > XML_MAX_LOOKUP_LIMIT)) &&
6dedca
         ((ctxt->options & XML_PARSE_HUGE) == 0)) {
6dedca
         xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
6dedca
-        ctxt->instate = XML_PARSER_EOF;
6dedca
+        xmlHaltParser(ctxt);
6dedca
     }
6dedca
     if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1))
6dedca
         return(ctxt->errNo);
6dedca
-- 
6dedca
2.5.0
6dedca