mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
576368 – htmlChunkParser with special attributes
* HTMLparser.c: htmlChunkParsing failed when the chunk ends inside element after some attribute which has a '>' char in its value.
This commit is contained in:
committed by
Daniel Veillard
parent
933e5de96c
commit
446e126de5
53
HTMLparser.c
53
HTMLparser.c
@ -4521,11 +4521,14 @@ 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 base, len;
|
int base, len;
|
||||||
htmlParserInputPtr in;
|
htmlParserInputPtr in;
|
||||||
const xmlChar *buf;
|
const xmlChar *buf;
|
||||||
int incomment = 0;
|
int incomment = 0;
|
||||||
|
int invalue = 0;
|
||||||
|
char valdellim = 0x0;
|
||||||
|
|
||||||
in = ctxt->input;
|
in = ctxt->input;
|
||||||
if (in == NULL) return(-1);
|
if (in == NULL) return(-1);
|
||||||
@ -4552,6 +4555,22 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
|
|||||||
base += 2;
|
base += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ignoreattrval) {
|
||||||
|
if (buf[base] == '"' || buf[base] == '\'') {
|
||||||
|
if (invalue) {
|
||||||
|
if (buf[base] == valdellim) {
|
||||||
|
invalue = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
valdellim = buf[base];
|
||||||
|
invalue = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (invalue) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (incomment) {
|
if (incomment) {
|
||||||
if (base + 3 > len)
|
if (base + 3 > len)
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -4731,7 +4750,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
|
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
|
||||||
(UPP(8) == 'E')) {
|
(UPP(8) == 'E')) {
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
@ -4764,7 +4783,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
if ((cur == '<') && (next == '!') &&
|
if ((cur == '<') && (next == '!') &&
|
||||||
(in->cur[2] == '-') && (in->cur[3] == '-')) {
|
(in->cur[2] == '-') && (in->cur[3] == '-')) {
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, '-', '-', '>', 1) < 0))
|
(htmlParseLookupSequence(ctxt, '-', '-', '>', 1, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
@ -4774,7 +4793,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->instate = XML_PARSER_MISC;
|
ctxt->instate = XML_PARSER_MISC;
|
||||||
} else if ((cur == '<') && (next == '?')) {
|
} else if ((cur == '<') && (next == '?')) {
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
@ -4788,7 +4807,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
|
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
|
||||||
(UPP(8) == 'E')) {
|
(UPP(8) == 'E')) {
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
@ -4824,7 +4843,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
if ((cur == '<') && (next == '!') &&
|
if ((cur == '<') && (next == '!') &&
|
||||||
(in->cur[2] == '-') && (in->cur[3] == '-')) {
|
(in->cur[2] == '-') && (in->cur[3] == '-')) {
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, '-', '-', '>', 1) < 0))
|
(htmlParseLookupSequence(ctxt, '-', '-', '>', 1, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
@ -4834,7 +4853,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->instate = XML_PARSER_PROLOG;
|
ctxt->instate = XML_PARSER_PROLOG;
|
||||||
} else if ((cur == '<') && (next == '?')) {
|
} else if ((cur == '<') && (next == '?')) {
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
@ -4871,7 +4890,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
if ((cur == '<') && (next == '!') &&
|
if ((cur == '<') && (next == '!') &&
|
||||||
(in->cur[2] == '-') && (in->cur[3] == '-')) {
|
(in->cur[2] == '-') && (in->cur[3] == '-')) {
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, '-', '-', '>', 1) < 0))
|
(htmlParseLookupSequence(ctxt, '-', '-', '>', 1, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
@ -4881,7 +4900,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->instate = XML_PARSER_EPILOG;
|
ctxt->instate = XML_PARSER_EPILOG;
|
||||||
} else if ((cur == '<') && (next == '?')) {
|
} else if ((cur == '<') && (next == '?')) {
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
@ -4931,7 +4950,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
failed = htmlParseStartTag(ctxt);
|
failed = htmlParseStartTag(ctxt);
|
||||||
@ -5056,7 +5075,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
int idx;
|
int idx;
|
||||||
xmlChar val;
|
xmlChar val;
|
||||||
|
|
||||||
idx = htmlParseLookupSequence(ctxt, '<', '/', 0, 0);
|
idx = htmlParseLookupSequence(ctxt, '<', '/', 0, 0, 1);
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
goto done;
|
goto done;
|
||||||
val = in->cur[idx + 2];
|
val = in->cur[idx + 2];
|
||||||
@ -5083,7 +5102,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
|
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
|
||||||
(UPP(8) == 'E')) {
|
(UPP(8) == 'E')) {
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
|
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
|
||||||
"Misplaced DOCTYPE declaration\n",
|
"Misplaced DOCTYPE declaration\n",
|
||||||
@ -5093,7 +5112,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(in->cur[2] == '-') && (in->cur[3] == '-')) {
|
(in->cur[2] == '-') && (in->cur[3] == '-')) {
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(
|
(htmlParseLookupSequence(
|
||||||
ctxt, '-', '-', '>', 1) < 0))
|
ctxt, '-', '-', '>', 1, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
@ -5103,7 +5122,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
} else if ((cur == '<') && (next == '?')) {
|
} else if ((cur == '<') && (next == '?')) {
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
@ -5131,7 +5150,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
break;
|
break;
|
||||||
} else if (cur == '&') {
|
} else if (cur == '&') {
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, ';', 0, 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, ';', 0, 0, 0, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
@ -5147,7 +5166,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
* data detection.
|
* data detection.
|
||||||
*/
|
*/
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, '<', 0, 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, '<', 0, 0, 0, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
@ -5173,7 +5192,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
if (avail < 2)
|
if (avail < 2)
|
||||||
goto done;
|
goto done;
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
htmlParseEndTag(ctxt);
|
htmlParseEndTag(ctxt);
|
||||||
if (ctxt->nameNr == 0) {
|
if (ctxt->nameNr == 0) {
|
||||||
|
Reference in New Issue
Block a user