1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-08 20:59:47 +03:00

444994 HTML chunked failure for attribute with <>

* HTMLparser.c: fix htmlParseLookupSequence to not save ctxt->checkIndex
  when the current buffer ends within an attribute value, as this
  information would be missed in next pass.
This commit is contained in:
Daniel Veillard
2009-08-25 14:42:16 +02:00
parent 85b07d188c
commit eeb9932990

View File

@ -4632,7 +4632,8 @@ htmlCreateDocParserCtxt(const xmlChar *cur, const char *encoding) {
static int static int
htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first, htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
xmlChar next, xmlChar third, int iscomment, xmlChar next, xmlChar third, int iscomment,
int ignoreattrval) { int ignoreattrval)
{
int base, len; int base, len;
htmlParserInputPtr in; htmlParserInputPtr in;
const xmlChar *buf; const xmlChar *buf;
@ -4641,11 +4642,16 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
char valdellim = 0x0; char valdellim = 0x0;
in = ctxt->input; in = ctxt->input;
if (in == NULL) return(-1); if (in == NULL)
return (-1);
base = in->cur - in->base; base = in->cur - in->base;
if (base < 0) return(-1); if (base < 0)
return (-1);
if (ctxt->checkIndex > base) if (ctxt->checkIndex > base)
base = ctxt->checkIndex; base = ctxt->checkIndex;
if (in->buf == NULL) { if (in->buf == NULL) {
buf = in->base; buf = in->base;
len = in->length; len = in->length;
@ -4653,11 +4659,14 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
buf = in->buf->buffer->content; buf = in->buf->buffer->content;
len = in->buf->buffer->use; len = in->buf->buffer->use;
} }
/* take into account the sequence length */ /* take into account the sequence length */
if (third) len -= 2; if (third)
else if (next) len --; len -= 2;
for (;base < len;base++) { else if (next)
if (!incomment && (base + 4 < len) && !iscomment) { len--;
for (; base < len; base++) {
if ((!incomment) && (base + 4 < len) && (!iscomment)) {
if ((buf[base] == '<') && (buf[base + 1] == '!') && if ((buf[base] == '<') && (buf[base + 1] == '!') &&
(buf[base + 2] == '-') && (buf[base + 3] == '-')) { (buf[base + 2] == '-') && (buf[base + 3] == '-')) {
incomment = 1; incomment = 1;
@ -4683,7 +4692,7 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
} }
if (incomment) { if (incomment) {
if (base + 3 > len) if (base + 3 > len)
return(-1); return (-1);
if ((buf[base] == '-') && (buf[base + 1] == '-') && if ((buf[base] == '-') && (buf[base + 1] == '-') &&
(buf[base + 2] == '>')) { (buf[base + 2] == '>')) {
incomment = 0; incomment = 0;
@ -4693,10 +4702,11 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
} }
if (buf[base] == first) { if (buf[base] == first) {
if (third != 0) { if (third != 0) {
if ((buf[base + 1] != next) || if ((buf[base + 1] != next) || (buf[base + 2] != third))
(buf[base + 2] != third)) continue; continue;
} else if (next != 0) { } else if (next != 0) {
if (buf[base + 1] != next) continue; if (buf[base + 1] != next)
continue;
} }
ctxt->checkIndex = 0; ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH #ifdef DEBUG_PUSH
@ -4713,9 +4723,10 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
"HPP: lookup '%c%c%c' found at %d\n", "HPP: lookup '%c%c%c' found at %d\n",
first, next, third, base); first, next, third, base);
#endif #endif
return(base - (in->cur - in->base)); return (base - (in->cur - in->base));
} }
} }
if ((!incomment) && (!invalue))
ctxt->checkIndex = base; ctxt->checkIndex = base;
#ifdef DEBUG_PUSH #ifdef DEBUG_PUSH
if (next == 0) if (next == 0)
@ -4726,9 +4737,10 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
"HPP: lookup '%c%c' failed\n", first, next); "HPP: lookup '%c%c' failed\n", first, next);
else else
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"HPP: lookup '%c%c%c' failed\n", first, next, third); "HPP: lookup '%c%c%c' failed\n", first, next,
third);
#endif #endif
return(-1); return (-1);
} }
/** /**