From: Erik Lundin Date: Tue, 13 Aug 2019 20:50:37 +0000 (+0200) Subject: Fixed #75245 Don't set content of elements with only whitespaces X-Git-Tag: php-7.4.0RC4~76 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6462c196897b8c5ccf606b8af8de790b77799de6;p=php Fixed #75245 Don't set content of elements with only whitespaces --- diff --git a/NEWS b/NEWS index fccb03ca09..a7f668fa8c 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 06c504884c..2cdff0e648 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -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) { diff --git a/ext/simplexml/tests/bug39662.phpt b/ext/simplexml/tests/bug39662.phpt index b07e90064f..5dc2b99a92 100644 --- a/ext/simplexml/tests/bug39662.phpt +++ b/ext/simplexml/tests/bug39662.phpt @@ -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) " diff --git a/ext/simplexml/tests/bug75245.phpt b/ext/simplexml/tests/bug75245.phpt new file mode 100644 index 0000000000..4a7a7caf0b --- /dev/null +++ b/ext/simplexml/tests/bug75245.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #75245 Don't set content of elements with only whitespaces +--SKIPIF-- + +--FILE-- + ')); +?> +===DONE=== +--EXPECT-- +object(SimpleXMLElement)#1 (2) { + ["test2"]=> + object(SimpleXMLElement)#2 (0) { + } + ["test3"]=> + object(SimpleXMLElement)#3 (0) { + } +} +===DONE===