From 45ffc88eca3784fd0d0b7790707b4d3bc631df47 Mon Sep 17 00:00:00 2001 From: Erik Lundin Date: Tue, 13 Aug 2019 22:50:37 +0200 Subject: [PATCH 1/3] Don't set content of elements with only whitespaces --- ext/simplexml/simplexml.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 06c504884cf7..2cdff0e648d7 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) { From be7d5dec4d64eb051902888901b9e4e06c4f8098 Mon Sep 17 00:00:00 2001 From: Erik Lundin Date: Tue, 13 Aug 2019 22:50:54 +0200 Subject: [PATCH 2/3] Add test for bug #75245 --- ext/simplexml/tests/bug75245.phpt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 ext/simplexml/tests/bug75245.phpt diff --git a/ext/simplexml/tests/bug75245.phpt b/ext/simplexml/tests/bug75245.phpt new file mode 100644 index 000000000000..4a7a7caf0bca --- /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=== From 4f01c26612f231262ba9ae0768749684f58ad721 Mon Sep 17 00:00:00 2001 From: Erik Lundin Date: Wed, 14 Aug 2019 09:22:18 +0200 Subject: [PATCH 3/3] Correct expect data from test for whitespace only elements (Bug #75245) --- ext/simplexml/tests/bug39662.phpt | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/ext/simplexml/tests/bug39662.phpt b/ext/simplexml/tests/bug39662.phpt index b07e90064fcf..5dc2b99a9248 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) "