diff --git a/HTMLparser.c b/HTMLparser.c index 69eed2bd3ed5ac3954e77cc23fa403ab9ef86999..1c112cc947f2500b79f10e498d9484fe21b7bd26 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -2471,6 +2471,10 @@ htmlParseName(htmlParserCtxtPtr ctxt) { (*in == '_') || (*in == '-') || (*in == ':') || (*in == '.')) in++; + + if (in == ctxt->input->end) + return(NULL); + if ((*in > 0) && (*in < 0x80)) { count = in - ctxt->input->cur; ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count); @@ -2514,6 +2518,10 @@ htmlParseNameComplex(xmlParserCtxtPtr ctxt) { NEXTL(l); c = CUR_CHAR(l); } + + if (ctxt->input->base > ctxt->input->cur - len) + return(NULL); + return(xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len)); } diff --git a/result/HTML/758605.html b/result/HTML/758605.html new file mode 100644 index 0000000000000000000000000000000000000000..a085cce392381aeab85de7fdb393326dc07d27d0 --- /dev/null +++ b/result/HTML/758605.html @@ -0,0 +1,3 @@ + +

& +

diff --git a/result/HTML/758605.html.err b/result/HTML/758605.html.err new file mode 100644 index 0000000000000000000000000000000000000000..2b82be66e463ca76ae3d7e37dffcb594028ba4ff --- /dev/null +++ b/result/HTML/758605.html.err @@ -0,0 +1,3 @@ +./test/HTML/758605.html:1: HTML parser error : htmlParseEntityRef: no name +ê + ^ diff --git a/result/HTML/758605.html.sax b/result/HTML/758605.html.sax new file mode 100644 index 0000000000000000000000000000000000000000..1f5cd3206d61ae0e3480a1641f421ea989483bf8 --- /dev/null +++ b/result/HTML/758605.html.sax @@ -0,0 +1,13 @@ +SAX.setDocumentLocator() +SAX.startDocument() +SAX.error: htmlParseEntityRef: no name +SAX.startElement(html) +SAX.startElement(body) +SAX.startElement(p) +SAX.characters(&, 1) +SAX.ignorableWhitespace( +, 1) +SAX.endElement(p) +SAX.endElement(body) +SAX.endElement(html) +SAX.endDocument() diff --git a/runtest.c b/runtest.c index 36fbe5ac787340e3606eccbd4f7b22634228bed5..bb74d2a82e2be682db4dc2bc0129362f4fbb90ee 100644 --- a/runtest.c +++ b/runtest.c @@ -1873,7 +1873,7 @@ pushParseTest(const char *filename, const char *result, ctxt = xmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename); xmlCtxtUseOptions(ctxt, options); cur += 4; - while (cur < size) { + do { if (cur + 1024 >= size) { #ifdef LIBXML_HTML_ENABLED if (options & XML_PARSE_HTML) @@ -1891,7 +1891,7 @@ pushParseTest(const char *filename, const char *result, xmlParseChunk(ctxt, base + cur, 1024, 0); cur += 1024; } - } + } while (cur < size); doc = ctxt->myDoc; #ifdef LIBXML_HTML_ENABLED if (options & XML_PARSE_HTML) diff --git a/test/HTML/758605.html b/test/HTML/758605.html new file mode 100644 index 0000000000000000000000000000000000000000..9b1b3c2478c4d618ecc750a4cbdbbe792109398c --- /dev/null +++ b/test/HTML/758605.html @@ -0,0 +1 @@ +&: