summaryrefslogtreecommitdiff
path: root/ext/dom/php_dom.c
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-03-11 13:02:09 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2020-04-07 13:04:14 +0200
commitefec22b7bedfb1eae2df72b84cf5ad229e0bdc1e (patch)
tree6a7aa5d3d1fec5cbc1dbe0c99c9204df0b5e999e /ext/dom/php_dom.c
parent656eac74fa6074aebc087bb73d2e4651f7dc8c9e (diff)
downloadphp-git-efec22b7bedfb1eae2df72b84cf5ad229e0bdc1e.tar.gz
Fix #78221: DOMNode::normalize() doesn't remove empty text nodes
If a text node is not followed by another text node, we remove it, if its textContent is empty.
Diffstat (limited to 'ext/dom/php_dom.c')
-rw-r--r--ext/dom/php_dom.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index 72ae3c3ffe..ed67f047fa 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -1383,6 +1383,14 @@ void dom_normalize (xmlNodePtr nodep)
break;
}
}
+ strContent = xmlNodeGetContent(child);
+ if (*strContent == '\0') {
+ nextp = child->next;
+ xmlUnlinkNode(child);
+ php_libxml_node_free_resource(child);
+ child = nextp;
+ continue;
+ }
break;
case XML_ELEMENT_NODE:
dom_normalize (child);