diff options
author | Nikita Popov <nikic@php.net> | 2016-08-30 12:43:41 +0200 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2016-08-30 12:53:50 +0200 |
commit | 6adb7e0b7a1d57407f5267293b8b8d63f74b60a7 (patch) | |
tree | 256e1a6ee155befd271fc3d5c8f16e23e4346db8 | |
parent | 07cc6a6ba2d8cebe2b375353491a26953b250149 (diff) | |
download | php-git-6adb7e0b7a1d57407f5267293b8b8d63f74b60a7.tar.gz |
Followup for bug #72971
Property writes did not respect the namespace either. This is an
incomplete fix in that it only handles the case where an existing
child element is modified, not when a new one is created.
-rw-r--r-- | ext/simplexml/simplexml.c | 2 | ||||
-rw-r--r-- | ext/simplexml/tests/bug72971_2.phpt | 35 |
2 files changed, 36 insertions, 1 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 7c1e68787c..1f70ddd684 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -607,7 +607,7 @@ long_dim: while (node) { SKIP_TEXT(node); - if (!xmlStrcmp(node->name, (xmlChar *)Z_STRVAL_P(member))) { + if (!xmlStrcmp(node->name, (xmlChar *)Z_STRVAL_P(member)) && match_ns(sxe, node, sxe->iter.nsprefix, sxe->iter.isprefix)) { newnode = node; ++counter; } diff --git a/ext/simplexml/tests/bug72971_2.phpt b/ext/simplexml/tests/bug72971_2.phpt new file mode 100644 index 0000000000..aa6e09438c --- /dev/null +++ b/ext/simplexml/tests/bug72971_2.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #72971 (2): SimpleXML property write does not respect namespace +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip simplexml extension is not loaded"; ?> +--FILE-- +<?php + +$xml = new SimpleXMLElement('<root xmlns:ns="ns"><foo>bar</foo><ns:foo>ns:bar</ns:foo></root>'); + +$xml->foo = 'new-bar'; +var_dump($xml->foo); +var_dump($xml->children('ns')->foo); + +$xml->children('ns')->foo = 'ns:new-bar'; +var_dump($xml->foo); +var_dump($xml->children('ns')->foo); + +?> +--EXPECT-- +object(SimpleXMLElement)#2 (1) { + [0]=> + string(7) "new-bar" +} +object(SimpleXMLElement)#3 (1) { + [0]=> + string(6) "ns:bar" +} +object(SimpleXMLElement)#3 (1) { + [0]=> + string(7) "new-bar" +} +object(SimpleXMLElement)#2 (1) { + [0]=> + string(10) "ns:new-bar" +} |