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 @@ -3,6 +3,10 @@ PHP NEWS
3
3
4
4
?? ??? ????, PHP 7.4.6
5
5
6
+ - DOM:
7
+ . Fixed bug #78221 (DOMNode::normalize() doesn't remove empty text nodes).
8
+ (cmb)
9
+
6
10
- MBString:
7
11
. Fixed bug #79441 (Segfault in mb_chr() if internal encoding is unsupported).
8
12
(Girgias)
Original file line number Diff line number Diff line change @@ -1385,6 +1385,14 @@ void dom_normalize (xmlNodePtr nodep)
1385
1385
break ;
1386
1386
}
1387
1387
}
1388
+ strContent = xmlNodeGetContent (child );
1389
+ if (* strContent == '\0' ) {
1390
+ nextp = child -> next ;
1391
+ xmlUnlinkNode (child );
1392
+ php_libxml_node_free_resource (child );
1393
+ child = nextp ;
1394
+ continue ;
1395
+ }
1388
1396
break ;
1389
1397
case XML_ELEMENT_NODE :
1390
1398
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