If a text node is not followed by another text node, we remove it, if
its textContent is empty.
. Fixed bug #79434 (PHP 7.3 and PHP-7.4 crash with NULL-pointer dereference
on !CS constant). (Nikita)
+- DOM:
+ . Fixed bug #78221 (DOMNode::normalize() doesn't remove empty text nodes).
+ (cmb)
+
- MBString:
. Fixed bug #79441 (Segfault in mb_chr() if internal encoding is unsupported).
(Girgias)
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);
--- /dev/null
+--TEST--
+Bug #78221 (DOMNode::normalize() doesn't remove empty text nodes)
+--SKIPIF--
+<?php
+if (!extension_loaded('dom')) die('skip dom extension not available');
+?>
+--FILE--
+<?php
+$doc = new DOMDocument();
+$doc->loadHTML('<p id=x>foo</p>');
+$p = $doc->getElementById('x');
+$p->childNodes[0]->textContent = '';
+$p->normalize();
+var_dump($p->childNodes->length);
+?>
+--EXPECT--
+int(0)