From 70bf754e24fcfa6c04a5de635dcc57f83464a8b1 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 1 Feb 2025 00:17:01 +0100 Subject: [PATCH] html: Fix pull-parsing of incomplete end tags Handle this HTML5 quirk in htmlParseEndTag. --- HTMLparser.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/HTMLparser.c b/HTMLparser.c index 5ba9ceb2..2321861e 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -3987,6 +3987,15 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt) SKIP(2); + if (ctxt->input->cur >= ctxt->input->end) { + htmlCheckParagraph(ctxt); + if ((ctxt->sax != NULL) && (!ctxt->disableSAX) && + (ctxt->sax->characters != NULL)) + ctxt->sax->characters(ctxt->userData, + BAD_CAST "') { SKIP(1); return; @@ -5129,14 +5138,6 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) { } case XML_PARSER_END_TAG: - if ((terminate) && (avail == 2)) { - htmlCheckParagraph(ctxt); - if ((ctxt->sax != NULL) && (!ctxt->disableSAX) && - (ctxt->sax->characters != NULL)) - ctxt->sax->characters(ctxt->userData, - BAD_CAST "