Skip to content

Commit 32b87f8

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed #75245 Don't set content of elements with only whitespaces
2 parents e7e8e45 + 6462c19 commit 32b87f8

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

NEWS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ PHP NEWS
4545
. Fixed bug #77800 (phpdbg segfaults on listing some conditional breakpoints).
4646
(krakjoe)
4747
. Fixed bug #77805 (phpdbg build fails when readline is shared). (krakjoe)
48-
48+
49+
- SimpleXML:
50+
. Fixed bug #75245 (Don't set content of elements with only whitespaces).
51+
(eriklundin)
52+
4953
- sodium:
5054
. Fixed bug #77646 (sign_detached() strings not terminated). (Frank)
5155

ext/simplexml/simplexml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ static HashTable *sxe_get_prop_hash(zend_object *object, int is_debug) /* {{{ */
12061206
}
12071207

12081208
while (node) {
1209-
if (node->children != NULL || node->prev != NULL || node->next != NULL) {
1209+
if (node->children != NULL || node->prev != NULL || node->next != NULL || xmlIsBlankNode(node)) {
12101210
SKIP_TEXT(node);
12111211
} else {
12121212
if (node->type == XML_TEXT_NODE) {

ext/simplexml/tests/bug39662.phpt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,9 @@ var_dump($clone->asXML());
1919
echo "Done\n";
2020
?>
2121
--EXPECTF--
22-
object(SimpleXMLElement)#%d (1) {
23-
[0]=>
24-
string(2) "
25-
26-
"
22+
object(SimpleXMLElement)#%d (0) {
2723
}
28-
object(SimpleXMLElement)#%d (1) {
29-
[0]=>
30-
string(2) "
31-
32-
"
24+
object(SimpleXMLElement)#%d (0) {
3325
}
3426
string(15) "<test>
3527

ext/simplexml/tests/bug75245.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #75245 Don't set content of elements with only whitespaces
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('simplexml')) die('skip simplexml not available');
6+
?>
7+
--FILE--
8+
<?php
9+
var_dump(simplexml_load_string('<test1><test2> </test2><test3></test3></test1>'));
10+
?>
11+
===DONE===
12+
--EXPECT--
13+
object(SimpleXMLElement)#1 (2) {
14+
["test2"]=>
15+
object(SimpleXMLElement)#2 (0) {
16+
}
17+
["test3"]=>
18+
object(SimpleXMLElement)#3 (0) {
19+
}
20+
}
21+
===DONE===

0 commit comments

Comments
 (0)