Browse files

fixed the comment streaming bug raised by Graham Bennett added to the

* parser.c: fixed the comment streaming bug raised by Graham Bennett
* test/badcomment.xml result//badcomment.xml*: added to the regression suite.
Daniel
  • Loading branch information...
1 parent a81d919 commit 6974feb0cf30d4201140ae2cf9c311bfdd87a4ff Daniel Veillard committed Feb 5, 2006
View
6 ChangeLog
@@ -1,3 +1,9 @@
+Sun Feb 5 03:41:39 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c: fixed the comment streaming bug raised by Graham Bennett
+ * test/badcomment.xml result//badcomment.xml*: added to the regression
+ suite.
+
Fri Feb 3 17:36:41 CET 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
* include/libxml/tree.h: Added the xmlDOMWrapCloneNode() to
View
10 parser.c
@@ -9838,8 +9838,14 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
} else if ((cur == '<') && (next == '!') &&
(ctxt->input->cur[2] == '-') &&
(ctxt->input->cur[3] == '-')) {
- if ((!terminate) &&
- (xmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
+ int term;
+
+ if (avail < 4)
+ goto done;
+ ctxt->input->cur += 4;
+ term = xmlParseLookupSequence(ctxt, '-', '-', '>');
+ ctxt->input->cur -= 4;
+ if ((!terminate) && (term < 0))
goto done;
xmlParseComment(ctxt);
ctxt->instate = XML_PARSER_CONTENT;
View
17 result/badcomment.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<foo>
+<!-- def='NT-Char'--><!-->Char</nt>* ']]&gt;' <nt def='NT-Char'>Char</nt>*))
+']]&gt;'</rhs>
+<com>CDATA sections</com>
+<rhs>| '&lt;!DOCTYPE'
+(<nt def="NT-Char">Char</nt> - ('[' | ']'))+
+('['
+<nt def="NT-simpleDTD">simpleDTD</nt>*
+']')? '&gt;'</rhs>
+<com>doc type declaration</com>
+<prod id="NT-simpleDTD"><lhs>simpleDTD</lhs>
+<rhs>'&lt;!&como;'
+(<nt def='NT-Char'>Char</nt>* -
+(<nt def='NT-Char'>Char</nt>* '&comc;' <nt def='NT-Char'>Char</nt>*))
+'&comc;&gt;'</rhs>-->
+</foo>
View
21 result/badcomment.xml.rde
@@ -0,0 +1,21 @@
+0 1 foo 0 0
+1 14 #text 0 1
+
+1 8 #comment 0 1 def='NT-Char'
+1 8 #comment 0 1 >Char</nt>* ']]&gt;' <nt def='NT-Char'>Char</nt>*))
+']]&gt;'</rhs>
+<com>CDATA sections</com>
+<rhs>| '&lt;!DOCTYPE'
+(<nt def="NT-Char">Char</nt> - ('[' | ']'))+
+('['
+<nt def="NT-simpleDTD">simpleDTD</nt>*
+']')? '&gt;'</rhs>
+<com>doc type declaration</com>
+<prod id="NT-simpleDTD"><lhs>simpleDTD</lhs>
+<rhs>'&lt;!&como;'
+(<nt def='NT-Char'>Char</nt>* -
+(<nt def='NT-Char'>Char</nt>* '&comc;' <nt def='NT-Char'>Char</nt>*))
+'&comc;&gt;'</rhs>
+1 14 #text 0 1
+
+0 15 foo 0 0
View
21 result/badcomment.xml.rdr
@@ -0,0 +1,21 @@
+0 1 foo 0 0
+1 14 #text 0 1
+
+1 8 #comment 0 1 def='NT-Char'
+1 8 #comment 0 1 >Char</nt>* ']]&gt;' <nt def='NT-Char'>Char</nt>*))
+']]&gt;'</rhs>
+<com>CDATA sections</com>
+<rhs>| '&lt;!DOCTYPE'
+(<nt def="NT-Char">Char</nt> - ('[' | ']'))+
+('['
+<nt def="NT-simpleDTD">simpleDTD</nt>*
+']')? '&gt;'</rhs>
+<com>doc type declaration</com>
+<prod id="NT-simpleDTD"><lhs>simpleDTD</lhs>
+<rhs>'&lt;!&como;'
+(<nt def='NT-Char'>Char</nt>* -
+(<nt def='NT-Char'>Char</nt>* '&comc;' <nt def='NT-Char'>Char</nt>*))
+'&comc;&gt;'</rhs>
+1 14 #text 0 1
+
+0 15 foo 0 0
View
24 result/badcomment.xml.sax
@@ -0,0 +1,24 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.startElement(foo)
+SAX.characters(
+, 1)
+SAX.comment( def='NT-Char')
+SAX.comment(>Char</nt>* ']]&gt;' <nt def='NT-Char'>Char</nt>*))
+']]&gt;'</rhs>
+<com>CDATA sections</com>
+<rhs>| '&lt;!DOCTYPE'
+(<nt def="NT-Char">Char</nt> - ('[' | ']'))+
+('['
+<nt def="NT-simpleDTD">simpleDTD</nt>*
+']')? '&gt;'</rhs>
+<com>doc type declaration</com>
+<prod id="NT-simpleDTD"><lhs>simpleDTD</lhs>
+<rhs>'&lt;!&como;'
+(<nt def='NT-Char'>Char</nt>* -
+(<nt def='NT-Char'>Char</nt>* '&comc;' <nt def='NT-Char'>Char</nt>*))
+'&comc;&gt;'</rhs>)
+SAX.characters(
+, 1)
+SAX.endElement(foo)
+SAX.endDocument()
View
24 result/badcomment.xml.sax2
@@ -0,0 +1,24 @@
+SAX.setDocumentLocator()
+SAX.startDocument()
+SAX.startElementNs(foo, NULL, NULL, 0, 0, 0)
+SAX.characters(
+, 1)
+SAX.comment( def='NT-Char')
+SAX.comment(>Char</nt>* ']]&gt;' <nt def='NT-Char'>Char</nt>*))
+']]&gt;'</rhs>
+<com>CDATA sections</com>
+<rhs>| '&lt;!DOCTYPE'
+(<nt def="NT-Char">Char</nt> - ('[' | ']'))+
+('['
+<nt def="NT-simpleDTD">simpleDTD</nt>*
+']')? '&gt;'</rhs>
+<com>doc type declaration</com>
+<prod id="NT-simpleDTD"><lhs>simpleDTD</lhs>
+<rhs>'&lt;!&como;'
+(<nt def='NT-Char'>Char</nt>* -
+(<nt def='NT-Char'>Char</nt>* '&comc;' <nt def='NT-Char'>Char</nt>*))
+'&comc;&gt;'</rhs>)
+SAX.characters(
+, 1)
+SAX.endElementNs(foo, NULL, NULL)
+SAX.endDocument()
View
17 result/noent/badcomment.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<foo>
+<!-- def='NT-Char'--><!-->Char</nt>* ']]&gt;' <nt def='NT-Char'>Char</nt>*))
+']]&gt;'</rhs>
+<com>CDATA sections</com>
+<rhs>| '&lt;!DOCTYPE'
+(<nt def="NT-Char">Char</nt> - ('[' | ']'))+
+('['
+<nt def="NT-simpleDTD">simpleDTD</nt>*
+']')? '&gt;'</rhs>
+<com>doc type declaration</com>
+<prod id="NT-simpleDTD"><lhs>simpleDTD</lhs>
+<rhs>'&lt;!&como;'
+(<nt def='NT-Char'>Char</nt>* -
+(<nt def='NT-Char'>Char</nt>* '&comc;' <nt def='NT-Char'>Char</nt>*))
+'&comc;&gt;'</rhs>-->
+</foo>
View
18 test/badcomment.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<foo>
+<!-- def='NT-Char'--><!-->Char</nt>* ']]&gt;' <nt def='NT-Char'>Char</nt>*))
+']]&gt;'</rhs>
+<com>CDATA sections</com>
+<rhs>| '&lt;!DOCTYPE'
+(<nt def="NT-Char">Char</nt> - ('[' | ']'))+
+('['
+<nt def="NT-simpleDTD">simpleDTD</nt>*
+']')? '&gt;'</rhs>
+<com>doc type declaration</com>
+<prod id="NT-simpleDTD"><lhs>simpleDTD</lhs>
+<rhs>'&lt;!&como;'
+(<nt def='NT-Char'>Char</nt>* -
+(<nt def='NT-Char'>Char</nt>* '&comc;' <nt def='NT-Char'>Char</nt>*))
+'&comc;&gt;'</rhs>-->
+</foo>

0 comments on commit 6974feb

Please sign in to comment.