Skip to content

Commit 6462c19

Browse files
eriklundinkrakjoe
authored andcommitted
Fixed #75245 Don't set content of elements with only whitespaces
1 parent 3709c03 commit 6462c19

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.4.0RC4
44

5+
- SimpleXML:
6+
. Fixed bug #75245 (Don't set content of elements with only whitespaces).
7+
(eriklundin)
58

69
03 Oct 2019, PHP 7.4.0RC3
710

ext/simplexml/simplexml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ static HashTable *sxe_get_prop_hash(zval *object, int is_debug) /* {{{ */
11971197
}
11981198

11991199
while (node) {
1200-
if (node->children != NULL || node->prev != NULL || node->next != NULL) {
1200+
if (node->children != NULL || node->prev != NULL || node->next != NULL || xmlIsBlankNode(node)) {
12011201
SKIP_TEXT(node);
12021202
} else {
12031203
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)