diff options
author | Erik Lundin <erik@coretech.se> | 2019-08-13 22:50:37 +0200 |
---|---|---|
committer | Joe Watkins <krakjoe@php.net> | 2019-10-02 08:17:04 +0200 |
commit | 6462c196897b8c5ccf606b8af8de790b77799de6 (patch) | |
tree | ed9b2d886e2f7d2442fcc9e82d2e25c61f610846 /ext/simplexml | |
parent | 3709c03cda0a7682e1cf0dbbd1bcfd7841f66faa (diff) | |
download | php-git-6462c196897b8c5ccf606b8af8de790b77799de6.tar.gz |
Fixed #75245 Don't set content of elements with only whitespaces
Diffstat (limited to 'ext/simplexml')
-rw-r--r-- | ext/simplexml/simplexml.c | 2 | ||||
-rw-r--r-- | ext/simplexml/tests/bug39662.phpt | 12 | ||||
-rw-r--r-- | ext/simplexml/tests/bug75245.phpt | 21 |
3 files changed, 24 insertions, 11 deletions
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) "<test> 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-- +<?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=== |