diff options
author | Anatol Belski <ab@php.net> | 2014-04-05 09:48:54 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2014-04-05 09:48:54 +0200 |
commit | a094f6d255e4eb7c3aaff5fd080d5307ffb41e0c (patch) | |
tree | febda0ad5a390e7612be5aa54ae94a3453855818 /ext/simplexml | |
parent | 38e084d312687d721812b85d9ffa83c5677d49f8 (diff) | |
parent | a3d6f28312f5a40fe8e8452f7a2db5cb7c53cce5 (diff) | |
download | php-git-a094f6d255e4eb7c3aaff5fd080d5307ffb41e0c.tar.gz |
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
updated NEWS
Fixed bug #66084 simplexml_load_string() mangles empty node name
Diffstat (limited to 'ext/simplexml')
-rw-r--r-- | ext/simplexml/simplexml.c | 2 | ||||
-rw-r--r-- | ext/simplexml/tests/bug66084_0.phpt | 68 | ||||
-rw-r--r-- | ext/simplexml/tests/bug66084_1.phpt | 17 |
3 files changed, 86 insertions, 1 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 363ea1fc44..f84e1e014d 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1129,7 +1129,7 @@ static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* {{ node = NULL; } else if (sxe->iter.type != SXE_ITER_CHILD) { - if ( !node->children || !node->parent || node->children->next || node->children->children || node->parent->children == node->parent->last ) { + if ( !node->children || !node->parent || !node->next || node->children->next || node->children->children || node->parent->children == node->parent->last ) { node = node->children; } else { iter_data = sxe->iter.data; diff --git a/ext/simplexml/tests/bug66084_0.phpt b/ext/simplexml/tests/bug66084_0.phpt new file mode 100644 index 0000000000..35f4daf876 --- /dev/null +++ b/ext/simplexml/tests/bug66084_0.phpt @@ -0,0 +1,68 @@ +--TEST-- +Bug #66084 simplexml_load_string() mangles empty node name, var_dump variant +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip simplexml not available"; ?> +--FILE-- +<?php +echo var_dump(simplexml_load_string('<a><b/><c><x/></c></a>')), "\n"; +echo var_dump(simplexml_load_string('<a><b/><d/><c><x/></c></a>')), "\n"; +echo var_dump(simplexml_load_string('<a><b/><c><d/><x/></c></a>')), "\n"; +echo var_dump(simplexml_load_string('<a><b/><c><d><x/></d></c></a>')), "\n"; +?> +--EXPECT-- +object(SimpleXMLElement)#1 (2) { + ["b"]=> + object(SimpleXMLElement)#2 (0) { + } + ["c"]=> + object(SimpleXMLElement)#3 (1) { + ["x"]=> + object(SimpleXMLElement)#4 (0) { + } + } +} + +object(SimpleXMLElement)#1 (3) { + ["b"]=> + object(SimpleXMLElement)#3 (0) { + } + ["d"]=> + object(SimpleXMLElement)#2 (0) { + } + ["c"]=> + object(SimpleXMLElement)#4 (1) { + ["x"]=> + object(SimpleXMLElement)#5 (0) { + } + } +} + +object(SimpleXMLElement)#1 (2) { + ["b"]=> + object(SimpleXMLElement)#4 (0) { + } + ["c"]=> + object(SimpleXMLElement)#2 (2) { + ["d"]=> + object(SimpleXMLElement)#3 (0) { + } + ["x"]=> + object(SimpleXMLElement)#5 (0) { + } + } +} + +object(SimpleXMLElement)#1 (2) { + ["b"]=> + object(SimpleXMLElement)#2 (0) { + } + ["c"]=> + object(SimpleXMLElement)#4 (1) { + ["d"]=> + object(SimpleXMLElement)#5 (1) { + ["x"]=> + object(SimpleXMLElement)#3 (0) { + } + } + } +} diff --git a/ext/simplexml/tests/bug66084_1.phpt b/ext/simplexml/tests/bug66084_1.phpt new file mode 100644 index 0000000000..80e91df7c6 --- /dev/null +++ b/ext/simplexml/tests/bug66084_1.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #66084 simplexml_load_string() mangles empty node name, json variant +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip simplexml not available"; ?> +<?php if (!extension_loaded("json")) print "skip json not available"; ?> +--FILE-- +<?php +echo json_encode(simplexml_load_string('<a><b/><c><x/></c></a>')), "\n"; +echo json_encode(simplexml_load_string('<a><b/><d/><c><x/></c></a>')), "\n"; +echo json_encode(simplexml_load_string('<a><b/><c><d/><x/></c></a>')), "\n"; +echo json_encode(simplexml_load_string('<a><b/><c><d><x/></d></c></a>')), "\n"; +?> +--EXPECT-- +{"b":{},"c":{"x":{}}} +{"b":{},"d":{},"c":{"x":{}}} +{"b":{},"c":{"d":{},"x":{}}} +{"b":{},"c":{"d":{"x":{}}}} |