html: Fix EOF handling in comments

This commit is contained in:
Nick Wellnhofer 2024-09-11 15:03:49 +02:00
parent 17e56ac54a
commit b19d353970

View File

@ -3196,13 +3196,29 @@ htmlParseComment(htmlParserCtxtPtr ctxt, int bogus) {
break;
}
} else {
if ((cur == '-') && (NXT(1) == '-')) {
if (NXT(2) == '>') {
SKIP(3);
break;
} else if ((NXT(2) == '!') && (NXT(3) == '>')) {
SKIP(4);
if (cur == '-') {
size_t avail = ctxt->input->end - ctxt->input->cur;
if (avail < 2) {
SKIP(1);
break;
} else if (NXT(1) == '-') {
if (avail < 3) {
SKIP(2);
break;
} else if (NXT(2) == '>') {
SKIP(3);
break;
} else if (NXT(2) == '!') {
if (avail < 4) {
SKIP(3);
break;
} else if (NXT(3) == '>') {
SKIP(4);
break;
}
}
}
}
}