1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-26 00:37:43 +03:00

html: Fix logic in htmlAutoClose

Note that the function is never called with a NULL newtag.

Fixes #591.
This commit is contained in:
Nick Wellnhofer
2023-09-21 17:01:35 +02:00
parent 81741ea4c0
commit c5890716a6

View File

@@ -1533,20 +1533,11 @@ htmlAutoCloseOnEnd(htmlParserCtxtPtr ctxt)
static void static void
htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag) htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag)
{ {
while ((newtag != NULL) && (ctxt->name != NULL) && if (newtag == NULL)
(htmlCheckAutoClose(newtag, ctxt->name))) {
if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
ctxt->sax->endElement(ctxt->userData, ctxt->name);
htmlnamePop(ctxt);
}
if (newtag == NULL) {
htmlAutoCloseOnEnd(ctxt);
return; return;
}
while ((newtag == NULL) && (ctxt->name != NULL) && while ((ctxt->name != NULL) &&
((xmlStrEqual(ctxt->name, BAD_CAST "head")) || (htmlCheckAutoClose(newtag, ctxt->name))) {
(xmlStrEqual(ctxt->name, BAD_CAST "body")) ||
(xmlStrEqual(ctxt->name, BAD_CAST "html")))) {
if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL)) if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
ctxt->sax->endElement(ctxt->userData, ctxt->name); ctxt->sax->endElement(ctxt->userData, ctxt->name);
htmlnamePop(ctxt); htmlnamePop(ctxt);