Skip to content

Commit

Permalink
Fixed #75245 Don't set content of elements with only whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
eriklundin authored and krakjoe committed Oct 2, 2019
1 parent 3709c03 commit 6462c19
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 7.4.0RC4

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

03 Oct 2019, PHP 7.4.0RC3

Expand Down
2 changes: 1 addition & 1 deletion ext/simplexml/simplexml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ static HashTable *sxe_get_prop_hash(zval *object, int is_debug) /* {{{ */
}

while (node) {
if (node->children != NULL || node->prev != NULL || node->next != NULL) {
if (node->children != NULL || node->prev != NULL || node->next != NULL || xmlIsBlankNode(node)) {
SKIP_TEXT(node);
} else {
if (node->type == XML_TEXT_NODE) {
Expand Down
12 changes: 2 additions & 10 deletions ext/simplexml/tests/bug39662.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,9 @@ var_dump($clone->asXML());
echo "Done\n";
?>
--EXPECTF--
object(SimpleXMLElement)#%d (1) {
[0]=>
string(2) "

"
object(SimpleXMLElement)#%d (0) {
}
object(SimpleXMLElement)#%d (1) {
[0]=>
string(2) "

"
object(SimpleXMLElement)#%d (0) {
}
string(15) "<test>

Expand Down
21 changes: 21 additions & 0 deletions ext/simplexml/tests/bug75245.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Bug #75245 Don't set content of elements with only whitespaces
--SKIPIF--
<?php
if (!extension_loaded('simplexml')) die('skip simplexml not available');
?>
--FILE--
<?php
var_dump(simplexml_load_string('<test1><test2> </test2><test3></test3></test1>'));
?>
===DONE===
--EXPECT--
object(SimpleXMLElement)#1 (2) {
["test2"]=>
object(SimpleXMLElement)#2 (0) {
}
["test3"]=>
object(SimpleXMLElement)#3 (0) {
}
}
===DONE===

0 comments on commit 6462c19

Please sign in to comment.