Blob Blame History Raw
From 17c73f2e605322aad492b670123a6939f7706f88 Mon Sep 17 00:00:00 2001
From: Daniel Veillard <veillard@redhat.com>
Date: Fri, 3 Aug 2012 12:03:31 +0800
Subject: [PATCH] More fixups on the push parser behaviour
To: libvir-list@redhat.com

Signed-off-by: Daniel Veillard <veillard@redhat.com>
---
 parser.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/parser.c b/parser.c
index f4ddc5b..6a9e54d 100644
--- a/parser.c
+++ b/parser.c
@@ -11561,13 +11561,17 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
 		    (ctxt->input->cur[7] == 'P') &&
 		    (ctxt->input->cur[8] == 'E')) {
 		    if ((!terminate) &&
-		        (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0))
+		        (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0)) {
+                        ctxt->progressive = XML_PARSER_DTD;
 			goto done;
+                    }
 #ifdef DEBUG_PUSH
 		    xmlGenericError(xmlGenericErrorContext,
 			    "PP: Parsing internal subset\n");
 #endif
 		    ctxt->inSubset = 1;
+                    ctxt->progressive = 1;
+		    ctxt->checkIndex = 0;
 		    xmlParseDocTypeDecl(ctxt);
 		    if (RAW == '[') {
 			ctxt->instate = XML_PARSER_DTD;
@@ -11959,12 +11963,23 @@ xmlParseCheckTransition(xmlParserCtxtPtr ctxt, const char *chunk, int size) {
             return(1);
         return(0);
     }
+    if (ctxt->instate == XML_PARSER_CDATA_SECTION) {
+        if (memchr(chunk, '>', size) != NULL)
+            return(1);
+        return(0);
+    }
     if (ctxt->progressive == XML_PARSER_PI) {
         if (memchr(chunk, '>', size) != NULL)
             return(1);
         return(0);
     }
-    if (ctxt->instate == XML_PARSER_DTD) {
+    if (ctxt->instate == XML_PARSER_END_TAG) {
+        if (memchr(chunk, '>', size) != NULL)
+            return(1);
+        return(0);
+    }
+    if ((ctxt->progressive == XML_PARSER_DTD) ||
+        (ctxt->instate == XML_PARSER_DTD)) {
         if (memchr(chunk, ']', size) != NULL)
             return(1);
         return(0);
-- 
1.7.11.4