From 17e56ac54a6f1f06d07a4afd4725fe6dd58fd1fe Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Wed, 11 Sep 2024 14:24:58 +0200 Subject: [PATCH] html: Fix parsing of end tags --- HTMLparser.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/HTMLparser.c b/HTMLparser.c index deb8d307..bf8f7057 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -3877,6 +3877,11 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt) } SKIP(2); + if (CUR == '>') { + SKIP(1); + return(0); + } + if (!IS_ASCII_LETTER(CUR)) { htmlParseComment(ctxt, /* bogus */ 1); return(0); @@ -3890,7 +3895,7 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt) * Parse and ignore attributes. */ SKIP_BLANKS; - while ((CUR != 0) && + while ((ctxt->input->cur < ctxt->input->end) && (CUR != '>') && ((CUR != '/') || (NXT(1) != '>')) && (ctxt->instate != XML_PARSER_EOF)) { @@ -3915,8 +3920,7 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt) } else if ((CUR == '/') && (NXT(1) == '>')) { SKIP(2); } else { - htmlParseErr(ctxt, XML_ERR_GT_REQUIRED, - "End tag : expected '>'\n", NULL, NULL); + return(0); } if (ctxt->options & HTML_PARSE_HTML5) { @@ -5192,8 +5196,14 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) { break; } case XML_PARSER_END_TAG: - if (avail < 2) + if ((terminate) && (avail == 2)) { + htmlCheckParagraph(ctxt); + if ((ctxt->sax != NULL) && (!ctxt->disableSAX) && + (ctxt->sax->characters != NULL)) + ctxt->sax->characters(ctxt->userData, + BAD_CAST "