1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-21 14:53:44 +03:00

Fix whitespace when serializing empty HTML documents

The old, non-recursive HTML serialization code would always terminate
the output with a newline. The new implementation omitted the newline
if the document node had no children. Readd the newline when
serializing empty documents.

Fixes #266.
This commit is contained in:
Nick Wellnhofer
2021-06-07 15:09:53 +02:00
parent 3e1aad4fe5
commit 92d9ab4c28

View File

@@ -763,11 +763,15 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
if (((xmlDocPtr) cur)->intSubset != NULL) { if (((xmlDocPtr) cur)->intSubset != NULL) {
htmlDtdDumpOutput(buf, (xmlDocPtr) cur, NULL); htmlDtdDumpOutput(buf, (xmlDocPtr) cur, NULL);
} }
/* Always validate cur->parent when descending. */ if (cur->children != NULL) {
if ((cur->parent == parent) && (cur->children != NULL)) { /* Always validate cur->parent when descending. */
parent = cur; if (cur->parent == parent) {
cur = cur->children; parent = cur;
continue; cur = cur->children;
continue;
}
} else {
xmlOutputBufferWriteString(buf, "\n");
} }
break; break;