Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit c7f8781

Browse files
committed
tree: Fix handling of empty strings in xmlNodeParseContent
We shouldn't create an empty text node to match the old behavior. Fixes #759.
1 parent 4a0d74d commit c7f8781

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

testparser.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
1212

1313
#include <string.h>
1414

15+
static int
16+
testNewDocNode(void) {
17+
xmlNodePtr node;
18+
int err = 0;
19+
20+
node = xmlNewDocNode(NULL, NULL, BAD_CAST "c", BAD_CAST "");
21+
if (node->children != NULL) {
22+
fprintf(stderr, "empty node has children\n");
23+
err = 1;
24+
}
25+
xmlFreeNode(node);
26+
27+
return err;
28+
}
29+
1530
static int
1631
testStandaloneWithEncoding(void) {
1732
xmlDocPtr doc;
@@ -521,6 +536,7 @@ int
521536
main(void) {
522537
int err = 0;
523538

539+
err |= testNewDocNode();
524540
err |= testStandaloneWithEncoding();
525541
err |= testUnsupportedEncoding();
526542
err |= testNodeGetContent();

tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ xmlNodeParseContentInternal(const xmlDoc *doc, xmlNodePtr parent,
12131213
else
12141214
remaining = len;
12151215

1216-
if (value == NULL)
1216+
if ((value == NULL) || (value[0] == 0))
12171217
goto done;
12181218

12191219
cur = value;

0 commit comments

Comments
 (0)