From 24a6149fc41925991bd43db798de7de3965e7e57 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 15 Sep 2024 19:18:40 +0200 Subject: [PATCH] html: Make sure that character data mode is reset --- HTMLparser.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/HTMLparser.c b/HTMLparser.c index f5fc5747..3c5e08ca 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -3649,6 +3649,8 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) { int i; int discardtag = 0; + ctxt->endCheckState = 0; + SKIP(1); atts = ctxt->atts; @@ -3841,6 +3843,8 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt) const xmlChar *oldname; int i; + ctxt->endCheckState = 0; + SKIP(2); if (CUR == '>') { @@ -4043,13 +4047,6 @@ htmlParseElementInternal(htmlParserCtxtPtr ctxt) { if (name == NULL) return(0); - /* - * Lookup the info for that element. - */ - info = htmlTagLookup(name); - if (info != NULL) - ctxt->endCheckState = info->dataMode; - if (ctxt->record_info) htmlNodeInfoPush(ctxt, &node_info); @@ -4071,6 +4068,11 @@ htmlParseElementInternal(htmlParserCtxtPtr ctxt) { return(0); SKIP(1); + /* + * Lookup the info for that element. + */ + info = htmlTagLookup(name); + /* * Check for an Empty Element from DTD definition */ @@ -4084,6 +4086,9 @@ htmlParseElementInternal(htmlParserCtxtPtr ctxt) { return(0); } + if (info != NULL) + ctxt->endCheckState = info->dataMode; + return(1); } @@ -4862,13 +4867,6 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) { if (name == NULL) break; - /* - * Lookup the info for that element. - */ - info = htmlTagLookup(name); - if (info != NULL) - ctxt->endCheckState = info->dataMode; - /* * Check for an Empty Element labeled the XML/SGML way */ @@ -4889,6 +4887,11 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) { break; SKIP(1); + /* + * Lookup the info for that element. + */ + info = htmlTagLookup(name); + /* * Check for an Empty Element from DTD definition */ @@ -4902,6 +4905,9 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) { htmlnamePop(ctxt); } + if (info != NULL) + ctxt->endCheckState = info->dataMode; + if (ctxt->record_info) htmlNodeInfoPush(ctxt, &node_info);