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 discardtag = 0;
|
||||
|
||||
if (ctxt->instate == XML_PARSER_EOF)
|
||||
return(-1);
|
||||
if ((ctxt == NULL) || (ctxt->input == NULL)) {
|
||||
htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
|
||||
"htmlParseStartTag: context error\n", NULL, NULL);
|
||||
@ -3537,7 +3539,8 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
|
||||
"htmlParseStartTag: invalid element name\n",
|
||||
NULL, NULL);
|
||||
/* 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;
|
||||
return -1;
|
||||
}
|
||||
@ -3910,6 +3913,10 @@ htmlParseContent(htmlParserCtxtPtr ctxt) {
|
||||
long cons = ctxt->nbChars;
|
||||
|
||||
GROW;
|
||||
|
||||
if (ctxt->instate == XML_PARSER_EOF)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Our tag or one of it's parent or children is ending.
|
||||
*/
|
||||
@ -4073,6 +4080,9 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
|
||||
int depth;
|
||||
const xmlChar *oldptr;
|
||||
|
||||
if (ctxt->instate == XML_PARSER_EOF)
|
||||
return;
|
||||
|
||||
if ((ctxt == NULL) || (ctxt->input == NULL)) {
|
||||
htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
|
||||
"htmlParseElement: context error\n", NULL, NULL);
|
||||
@ -6064,6 +6074,10 @@ htmlCtxtUseOptions(htmlParserCtxtPtr ctxt, int options)
|
||||
ctxt->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;
|
||||
return (options);
|
||||
}
|
||||
|
Reference in New Issue
Block a user