summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Watkins <krakjoe@php.net>2017-01-02 11:59:15 +0000
committerJoe Watkins <krakjoe@php.net>2017-01-02 11:59:15 +0000
commit6a1d3c948bd2364b59f5fd87f4ef906109b3d12c (patch)
treeceea3ea6a17d796dd193ebf5103fb83041ae2193
parentf8b291d2885c7b9a92d6a1af9f630ad619e4c875 (diff)
parent156781baf5b7690dbbfeae90f5cc2a8390fb685f (diff)
downloadphp-git-6a1d3c948bd2364b59f5fd87f4ef906109b3d12c.tar.gz
Merge branch 'PHP-7.1'
* PHP-7.1: news entry for PR #2267 Fixed #67474 (getElementsByTagNameNS and default namespace) Add (failing) testcase for bug #67474
-rw-r--r--ext/dom/php_dom.c2
-rw-r--r--ext/dom/tests/bug67474.phpt18
2 files changed, 19 insertions, 1 deletions
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index 56fa38055c..20623c4681 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -1345,7 +1345,7 @@ xmlNode *dom_get_elements_by_tag_name_ns_raw(xmlNodePtr nodep, char *ns, char *l
while (nodep != NULL && (*cur <= index || index == -1)) {
if (nodep->type == XML_ELEMENT_NODE) {
if (xmlStrEqual(nodep->name, (xmlChar *)local) || xmlStrEqual((xmlChar *)"*", (xmlChar *)local)) {
- if (ns == NULL || (nodep->ns != NULL && (xmlStrEqual(nodep->ns->href, (xmlChar *)ns) || xmlStrEqual((xmlChar *)"*", (xmlChar *)ns)))) {
+ if (ns == NULL || (!strcmp(ns, "") && nodep->ns == NULL) || (nodep->ns != NULL && (xmlStrEqual(nodep->ns->href, (xmlChar *)ns) || xmlStrEqual((xmlChar *)"*", (xmlChar *)ns)))) {
if (*cur == index) {
ret = nodep;
break;
diff --git a/ext/dom/tests/bug67474.phpt b/ext/dom/tests/bug67474.phpt
new file mode 100644
index 0000000000..953127fa0b
--- /dev/null
+++ b/ext/dom/tests/bug67474.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #67474 getElementsByTagNameNS and default namespace
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+$doc = new DOMDocument();
+$doc->loadXML('<root xmlns:x="x"><a/><x:a/></root>');
+$list = $doc->getElementsByTagNameNS('', 'a');
+var_dump($list->length);
+$list = $doc->getElementsByTagNameNS(null, 'a');
+var_dump($list->length);
+?>
+--EXPECT--
+int(1)
+int(1)