From: Nikita Popov Date: Tue, 30 Aug 2016 08:54:31 +0000 (+0200) Subject: Fix bug #72971 X-Git-Tag: php-7.0.11RC1~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07cc6a6ba2d8cebe2b375353491a26953b250149;p=php Fix bug #72971 --- diff --git a/NEWS b/NEWS index 3bc47ecd4d..5e7c69085e 100644 --- a/NEWS +++ b/NEWS @@ -76,6 +76,9 @@ PHP NEWS . Fixed bug #72940 (SID always return "name=ID", even if session cookie exist). (Yasuo) +- SimpleXML: + . Fixed bug #72971 (SimpleXML isset/unset do not respect namespace). (Nikita) + - Standard: . Fixed bug #55451 (substr_compare NULL length interpreted as 0). (Lauri Kenttä) diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 3b27656786..7c1e68787c 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -807,7 +807,7 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend while (node) { xmlNodePtr nnext; nnext = node->next; - if ((node->type == XML_ELEMENT_NODE) && !xmlStrcmp(node->name, (xmlChar *)Z_STRVAL_P(member))) { + if (node->type == XML_ELEMENT_NODE && !xmlStrcmp(node->name, (xmlChar *)Z_STRVAL_P(member)) && match_ns(sxe, node, sxe->iter.nsprefix, sxe->iter.isprefix)) { break; } node = nnext; @@ -937,7 +937,7 @@ static void sxe_prop_dim_delete(zval *object, zval *member, zend_bool elements, 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)) { xmlUnlinkNode(node); php_libxml_node_free_resource(node); } diff --git a/ext/simplexml/tests/bug72971.phpt b/ext/simplexml/tests/bug72971.phpt new file mode 100644 index 0000000000..ff7ded02ef --- /dev/null +++ b/ext/simplexml/tests/bug72971.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #72971: SimpleXML isset/unset do not respect namespace +--SKIPIF-- + +--FILE-- +barns:barns:bar2'); +var_dump(isset($xml->foo2)); +unset($xml->foo); +var_dump($xml->children('ns')); + +?> +--EXPECT-- +bool(false) +object(SimpleXMLElement)#2 (2) { + ["foo"]=> + string(6) "ns:bar" + ["foo2"]=> + string(7) "ns:bar2" +}