1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +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
htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag)
{
while ((newtag != NULL) && (ctxt->name != 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);
if (newtag == NULL)
return;
}
while ((newtag == NULL) && (ctxt->name != NULL) &&
((xmlStrEqual(ctxt->name, BAD_CAST "head")) ||
(xmlStrEqual(ctxt->name, BAD_CAST "body")) ||
(xmlStrEqual(ctxt->name, BAD_CAST "html")))) {
while ((ctxt->name != NULL) &&
(htmlCheckAutoClose(newtag, ctxt->name))) {
if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
ctxt->sax->endElement(ctxt->userData, ctxt->name);
htmlnamePop(ctxt);