File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ PHP NEWS
6
6
. Fixed bug #79434 (PHP 7.3 and PHP-7.4 crash with NULL-pointer dereference
7
7
on !CS constant). (Nikita)
8
8
9
+ - DOM:
10
+ . Fixed bug #78221 (DOMNode::normalize() doesn't remove empty text nodes).
11
+ (cmb)
12
+
9
13
- MBString:
10
14
. Fixed bug #79441 (Segfault in mb_chr() if internal encoding is unsupported).
11
15
(Girgias)
Original file line number Diff line number Diff line change @@ -1383,6 +1383,14 @@ void dom_normalize (xmlNodePtr nodep)
1383
1383
break ;
1384
1384
}
1385
1385
}
1386
+ strContent = xmlNodeGetContent (child );
1387
+ if (* strContent == '\0' ) {
1388
+ nextp = child -> next ;
1389
+ xmlUnlinkNode (child );
1390
+ php_libxml_node_free_resource (child );
1391
+ child = nextp ;
1392
+ continue ;
1393
+ }
1386
1394
break ;
1387
1395
case XML_ELEMENT_NODE :
1388
1396
dom_normalize (child );
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #78221 (DOMNode::normalize() doesn't remove empty text nodes)
3
+ --SKIPIF--
4
+ <?php
5
+ if (!extension_loaded ('dom ' )) die ('skip dom extension not available ' );
6
+ ?>
7
+ --FILE--
8
+ <?php
9
+ $ doc = new DOMDocument ();
10
+ $ doc ->loadHTML ('<p id=x>foo</p> ' );
11
+ $ p = $ doc ->getElementById ('x ' );
12
+ $ p ->childNodes [0 ]->textContent = '' ;
13
+ $ p ->normalize ();
14
+ var_dump ($ p ->childNodes ->length );
15
+ ?>
16
+ --EXPECT--
17
+ int(0)
You can’t perform that action at this time.
0 commit comments