1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

htmlParseComment: handle abruptly-closed comments

See guidance provided on abrutply-closed comments here:

https://html.spec.whatwg.org/multipage/parsing.html#parse-error-abrupt-closing-of-empty-comment
This commit is contained in:
Mike Dalessio
2021-07-17 14:36:53 -04:00
committed by Nick Wellnhofer
parent 24cdc89006
commit d7b287b94c
5 changed files with 24 additions and 8 deletions

View File

@ -3484,10 +3484,20 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
q = CUR_CHAR(ql);
if (q == 0)
goto unfinished;
if (q == '>') {
htmlParseErr(ctxt, XML_ERR_COMMENT_ABRUPTLY_ENDED, "Comment abruptly ended", NULL, NULL);
cur = '>';
goto finished;
}
NEXTL(ql);
r = CUR_CHAR(rl);
if (r == 0)
goto unfinished;
if (q == '-' && r == '>') {
htmlParseErr(ctxt, XML_ERR_COMMENT_ABRUPTLY_ENDED, "Comment abruptly ended", NULL, NULL);
cur = '>';
goto finished;
}
NEXTL(rl);
cur = CUR_CHAR(l);
while ((cur != 0) &&
@ -3535,6 +3545,7 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
cur = next;
l = nl;
}
finished:
buf[len] = 0;
if (cur == '>') {
NEXT;