1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-01-11 05:17:37 +03:00

html: Allow attributes in end tags

Attribute are syntactically allowed in HTML5 end tags but otherwise
ignored.
This commit is contained in:
Nick Wellnhofer 2023-05-04 15:59:31 +02:00
parent f2272c231b
commit a80f8b64a9
5 changed files with 27 additions and 16 deletions

View File

@ -3980,20 +3980,39 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt)
name = htmlParseHTMLName(ctxt, 0);
if (name == NULL)
return (0);
/*
* We should definitely be at the ending "S? '>'" part
* Parse and ignore attributes.
*/
SKIP_BLANKS;
if (CUR != '>') {
while ((CUR != 0) &&
(CUR != '>') &&
((CUR != '/') || (NXT(1) != '>')) &&
(ctxt->instate != XML_PARSER_EOF)) {
xmlChar *attvalue = NULL;
/* unexpected-solidus-in-tag */
if (CUR == '/') {
NEXT;
SKIP_BLANKS;
continue;
}
GROW;
htmlParseAttribute(ctxt, &attvalue);
if (attvalue != NULL)
xmlFree(attvalue);
SKIP_BLANKS;
}
if (CUR == '>') {
NEXT;
} else if ((CUR == '/') && (NXT(1) == '>')) {
SKIP(2);
} else {
htmlParseErr(ctxt, XML_ERR_GT_REQUIRED,
"End tag : expected '>'\n", NULL, NULL);
/* Skip to next '>' */
while ((PARSER_STOPPED(ctxt) == 0) &&
(CUR != 0) && (CUR != '>'))
NEXT;
}
if (CUR == '>')
NEXT;
/*
* if we ignored misplaced tags in htmlParseStartTag don't pop them

View File

@ -40,9 +40,6 @@ om/ad_static.asp?pid=2097&sid=1881&asid=7708"></a></IFRAME></CENTER></LI></FONT>
./test/HTML/doc3.htm:795: HTML parser error : Unexpected end tag : iframe
document.write("42DF8478957377></IFRAME>");
^
./test/HTML/doc3.htm:804: HTML parser error : End tag : expected '>'
document.write("RIPT>");
^
./test/HTML/doc3.htm:804: HTML parser error : Unexpected end tag : sc");
document.write("RIPT>");
^

View File

@ -2696,7 +2696,6 @@ SAX.cdata(
SAX.error: Unexpected end tag : iframe
SAX.cdata(");
} else if ((parseI, 463)
SAX.error: End tag : expected '>'
SAX.error: Unexpected end tag : sc");
SAX.cdata(");
} else {

View File

@ -217,9 +217,6 @@ wired.com&BANNER=Sprint" style="text-decoration:none"><font color="#000000">Spri
./test/HTML/wired.html:408: HTML parser error : Opening and ending tag mismatch: a and font
com&BANNER=Sprint" style="text-decoration:none"><font color="#000000">Sprint</a>
^
./test/HTML/wired.html:408: HTML parser error : End tag : expected '>'
Sprint" style="text-decoration:none"><font color="#000000">Sprint</a></i></font<
^
./test/HTML/wired.html:408: HTML parser error : Unexpected end tag : font<
" style="text-decoration:none"><font color="#000000">Sprint</a></i></font</font>
^

View File

@ -1960,7 +1960,6 @@ SAX.error: Opening and ending tag mismatch: a and font
SAX.endElement(font)
SAX.endElement(a)
SAX.endElement(i)
SAX.error: End tag : expected '>'
SAX.error: Unexpected end tag : font<
SAX.startElement(br)
SAX.endElement(br)