1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-27 18:50:07 +03:00

tree: Fix handling of empty strings in xmlNodeParseContent

We shouldn't create an empty text node to match the old behavior.

Fixes #759.
This commit is contained in:
Nick Wellnhofer 2024-07-03 15:54:32 +02:00
parent 46ec621eb7
commit 944cc23c84
2 changed files with 17 additions and 1 deletions

View File

@ -13,6 +13,21 @@
#include <string.h>
static int
testNewDocNode(void) {
xmlNodePtr node;
int err = 0;
node = xmlNewDocNode(NULL, NULL, BAD_CAST "c", BAD_CAST "");
if (node->children != NULL) {
fprintf(stderr, "empty node has children\n");
err = 1;
}
xmlFreeNode(node);
return err;
}
static int
testStandaloneWithEncoding(void) {
xmlDocPtr doc;
@ -631,6 +646,7 @@ int
main(void) {
int err = 0;
err |= testNewDocNode();
err |= testStandaloneWithEncoding();
err |= testUnsupportedEncoding();
err |= testNodeGetContent();

2
tree.c
View File

@ -1214,7 +1214,7 @@ xmlNodeParseContentInternal(const xmlDoc *doc, xmlNodePtr parent,
else
remaining = len;
if (value == NULL)
if ((value == NULL) || (value[0] == 0))
goto done;
cur = value;