Skip to content

Commit 243dff2

Browse files
committed
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: news entry for PR #2267 Fixed #67474 (getElementsByTagNameNS and default namespace) Add (failing) testcase for bug #67474
2 parents 5324865 + 9f4d05a commit 243dff2

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ext/dom/php_dom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,7 @@ xmlNode *dom_get_elements_by_tag_name_ns_raw(xmlNodePtr nodep, char *ns, char *l
13451345
while (nodep != NULL && (*cur <= index || index == -1)) {
13461346
if (nodep->type == XML_ELEMENT_NODE) {
13471347
if (xmlStrEqual(nodep->name, (xmlChar *)local) || xmlStrEqual((xmlChar *)"*", (xmlChar *)local)) {
1348-
if (ns == NULL || (nodep->ns != NULL && (xmlStrEqual(nodep->ns->href, (xmlChar *)ns) || xmlStrEqual((xmlChar *)"*", (xmlChar *)ns)))) {
1348+
if (ns == NULL || (!strcmp(ns, "") && nodep->ns == NULL) || (nodep->ns != NULL && (xmlStrEqual(nodep->ns->href, (xmlChar *)ns) || xmlStrEqual((xmlChar *)"*", (xmlChar *)ns)))) {
13491349
if (*cur == index) {
13501350
ret = nodep;
13511351
break;

ext/dom/tests/bug67474.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #67474 getElementsByTagNameNS and default namespace
3+
--SKIPIF--
4+
<?php
5+
require_once('skipif.inc');
6+
?>
7+
--FILE--
8+
<?php
9+
$doc = new DOMDocument();
10+
$doc->loadXML('<root xmlns:x="x"><a/><x:a/></root>');
11+
$list = $doc->getElementsByTagNameNS('', 'a');
12+
var_dump($list->length);
13+
$list = $doc->getElementsByTagNameNS(null, 'a');
14+
var_dump($list->length);
15+
?>
16+
--EXPECT--
17+
int(1)
18+
int(1)

0 commit comments

Comments
 (0)