1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-24 21:33:51 +03:00

fixed a very serious (looping) validation bug Daniel

* parser.c valid.c result/valid/rss.xml result/valid/rss.xml.err:
  fixed a very serious (looping) validation bug
Daniel
This commit is contained in:
Daniel Veillard 2001-10-18 14:57:24 +00:00
parent 3c01b1d81b
commit ce2c2f0997
4 changed files with 60 additions and 6 deletions

View File

@ -1,3 +1,8 @@
Thu Oct 18 16:56:23 CEST 2001 Daniel Veillard <daniel@veillard.com>
* parser.c valid.c result/valid/rss.xml result/valid/rss.xml.err:
fixed a very serious (looping) validation bug
Wed Oct 17 11:56:25 EDT 2001 Daniel Veillard <daniel@veillard.com>
* include/libxml/globals.h include/libxml/threads.h threads.c

View File

@ -4443,12 +4443,54 @@ xmlParseElementChildrenContentDecl
ret->ocur = XML_ELEMENT_CONTENT_OPT;
NEXT;
} else if (RAW == '*') {
if (ret != NULL)
if (ret != NULL) {
ret->ocur = XML_ELEMENT_CONTENT_MULT;
cur = ret;
/*
* Some normalization:
* (a | b* | c?)* == (a | b | c)*
*/
while (cur->type == XML_ELEMENT_CONTENT_OR) {
if ((cur->c1 != NULL) &&
((cur->c1->ocur == XML_ELEMENT_CONTENT_OPT) ||
(cur->c1->ocur == XML_ELEMENT_CONTENT_MULT)))
cur->c1->ocur = XML_ELEMENT_CONTENT_ONCE;
if ((cur->c2 != NULL) &&
((cur->c2->ocur == XML_ELEMENT_CONTENT_OPT) ||
(cur->c2->ocur == XML_ELEMENT_CONTENT_MULT)))
cur->c2->ocur = XML_ELEMENT_CONTENT_ONCE;
cur = cur->c2;
}
}
NEXT;
} else if (RAW == '+') {
if (ret != NULL)
if (ret != NULL) {
int found = 0;
ret->ocur = XML_ELEMENT_CONTENT_PLUS;
/*
* Some normalization:
* (a | b*)+ == (a | b)*
* (a | b?)+ == (a | b)*
*/
while (cur->type == XML_ELEMENT_CONTENT_OR) {
if ((cur->c1 != NULL) &&
((cur->c1->ocur == XML_ELEMENT_CONTENT_OPT) ||
(cur->c1->ocur == XML_ELEMENT_CONTENT_MULT))) {
cur->c1->ocur = XML_ELEMENT_CONTENT_ONCE;
found = 1;
}
if ((cur->c2 != NULL) &&
((cur->c2->ocur == XML_ELEMENT_CONTENT_OPT) ||
(cur->c2->ocur == XML_ELEMENT_CONTENT_MULT))) {
cur->c2->ocur = XML_ELEMENT_CONTENT_ONCE;
found = 1;
}
cur = cur->c2;
}
if (found)
ret->ocur = XML_ELEMENT_CONTENT_MULT;
}
NEXT;
}
return(ret);

View File

@ -17,15 +17,15 @@
Based on RSS DTD originally created by
Lars Marius Garshol - larsga@ifi.uio.no.
$Id: rss-0.91.dtd,v 1.1 1999/07/25 07:59:31 danda Exp $
$Id: rss.xml,v 1.1 2001/04/20 13:48:21 veillard Exp $
--><!ELEMENT rss (channel)>
<!ATTLIST rss version CDATA #REQUIRED>
<!-- must be "0.91"> --><!ELEMENT channel (title | description | link | language | item+ | rating? | image? | textinput? | copyright? | pubDate? | lastBuildDate? | docs? | managingEditor? | webMaster? | skipHours? | skipDays?)*>
<!-- must be "0.91"> --><!ELEMENT channel (title | description | link | language | item+ | rating | image | textinput | copyright | pubDate | lastBuildDate | docs | managingEditor | webMaster | skipHours | skipDays)*>
<!ELEMENT title (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT link (#PCDATA)>
<!ELEMENT image (title | url | link | width? | height? | description?)*>
<!ELEMENT image (title | url | link | width | height | description)*>
<!ELEMENT url (#PCDATA)>
<!ELEMENT item (title | link | description)*>
<!ELEMENT textinput (title | description | name | link)*>

View File

@ -199,6 +199,11 @@ xmlValidPrintNode(xmlNodePtr cur) {
case XML_HTML_DOCUMENT_NODE:
xmlGenericError(xmlGenericErrorContext, "?html? ");
break;
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
xmlGenericError(xmlGenericErrorContext, "?docb? ");
break;
#endif
case XML_DTD_NODE:
xmlGenericError(xmlGenericErrorContext, "?dtd? ");
break;
@ -3395,6 +3400,8 @@ cont:
* of handling epsilon transition in NFAs.
*/
if ((CONT != NULL) &&
((CONT->parent == NULL) ||
(CONT->parent->type != XML_ELEMENT_CONTENT_OR)) &&
((CONT->ocur == XML_ELEMENT_CONTENT_MULT) ||
(CONT->ocur == XML_ELEMENT_CONTENT_OPT) ||
((CONT->ocur == XML_ELEMENT_CONTENT_PLUS) && (OCCURENCE)))) {
@ -3600,7 +3607,7 @@ analyze:
break;
}
DEBUG_VALID_MSG("Mult branch succeeded, continuing");
SET_OCCURENCE;
/* SET_OCCURENCE; */
goto cont;
}
}