mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-28 00:21:53 +03:00
592430 - HTML parser runs into endless loop
* HTMLparser.c: fix the problem with detection erroring absolutely, and properly popping up the stack when in EOF, also passes XML_PARSE_HUGE when decoding options.
This commit is contained in:
16
HTMLparser.c
16
HTMLparser.c
@ -3519,6 +3519,8 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
|
|||||||
int i;
|
int i;
|
||||||
int discardtag = 0;
|
int discardtag = 0;
|
||||||
|
|
||||||
|
if (ctxt->instate == XML_PARSER_EOF)
|
||||||
|
return(-1);
|
||||||
if ((ctxt == NULL) || (ctxt->input == NULL)) {
|
if ((ctxt == NULL) || (ctxt->input == NULL)) {
|
||||||
htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
|
htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
|
||||||
"htmlParseStartTag: context error\n", NULL, NULL);
|
"htmlParseStartTag: context error\n", NULL, NULL);
|
||||||
@ -3537,7 +3539,8 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
|
|||||||
"htmlParseStartTag: invalid element name\n",
|
"htmlParseStartTag: invalid element name\n",
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
/* Dump the bogus tag like browsers do */
|
/* Dump the bogus tag like browsers do */
|
||||||
while ((IS_CHAR_CH(CUR)) && (CUR != '>'))
|
while ((IS_CHAR_CH(CUR)) && (CUR != '>') &&
|
||||||
|
(ctxt->instate != XML_PARSER_EOF))
|
||||||
NEXT;
|
NEXT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -3910,6 +3913,10 @@ htmlParseContent(htmlParserCtxtPtr ctxt) {
|
|||||||
long cons = ctxt->nbChars;
|
long cons = ctxt->nbChars;
|
||||||
|
|
||||||
GROW;
|
GROW;
|
||||||
|
|
||||||
|
if (ctxt->instate == XML_PARSER_EOF)
|
||||||
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Our tag or one of it's parent or children is ending.
|
* Our tag or one of it's parent or children is ending.
|
||||||
*/
|
*/
|
||||||
@ -4073,6 +4080,9 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
|
|||||||
int depth;
|
int depth;
|
||||||
const xmlChar *oldptr;
|
const xmlChar *oldptr;
|
||||||
|
|
||||||
|
if (ctxt->instate == XML_PARSER_EOF)
|
||||||
|
return;
|
||||||
|
|
||||||
if ((ctxt == NULL) || (ctxt->input == NULL)) {
|
if ((ctxt == NULL) || (ctxt->input == NULL)) {
|
||||||
htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
|
htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
|
||||||
"htmlParseElement: context error\n", NULL, NULL);
|
"htmlParseElement: context error\n", NULL, NULL);
|
||||||
@ -6064,6 +6074,10 @@ htmlCtxtUseOptions(htmlParserCtxtPtr ctxt, int options)
|
|||||||
ctxt->options |= HTML_PARSE_COMPACT;
|
ctxt->options |= HTML_PARSE_COMPACT;
|
||||||
options -= HTML_PARSE_COMPACT;
|
options -= HTML_PARSE_COMPACT;
|
||||||
}
|
}
|
||||||
|
if (options & XML_PARSE_HUGE) {
|
||||||
|
ctxt->options |= XML_PARSE_HUGE;
|
||||||
|
options -= XML_PARSE_HUGE;
|
||||||
|
}
|
||||||
ctxt->dictNames = 0;
|
ctxt->dictNames = 0;
|
||||||
return (options);
|
return (options);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user