Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ PHP NEWS
return value of php_cli_server_client_send_through()). (Lazizbek Ergashev)

- DOM:
. Fixed NamedNodeMap::getNamedItemNS() with an empty URI not matching
the null namespace in spec-following mode. (iliaal)
. Fixed a use-after-free when cloning a DOMNameSpaceNode after
DOMDocument::xinclude(). (iliaal)
. Fixed bug GH-23331 (UAF when node_list_unlink() skips attribute children
Expand Down
3 changes: 3 additions & 0 deletions ext/dom/namednodemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ PHP_METHOD(DOMNamedNodeMap, getNamedItemNS)
objmap = (dom_nnodemap_object *)intern->ptr;

if (objmap != NULL) {
if (urilen == 0 && objmap->baseobj != NULL && objmap->nodetype != XML_NOTATION_NODE && objmap->nodetype != XML_ENTITY_NODE && php_dom_follow_spec_intern(objmap->baseobj)) {
uri = NULL;
}
if ((objmap->nodetype == XML_NOTATION_NODE) ||
objmap->nodetype == XML_ENTITY_NODE) {
if (objmap->ht) {
Expand Down
25 changes: 25 additions & 0 deletions ext/dom/tests/modern/spec/NamedNodeMap_getNamedItemNS.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
Comment thread
iliaal marked this conversation as resolved.
getNamedItemNS() with an empty URI must look up the null namespace
--EXTENSIONS--
dom
--FILE--
<?php
$d = new DOMDocument();
$d->loadXML('<root xmlns:q="urn:q" bar="no-ns" q:bar="ns"/>');
$a = $d->documentElement->attributes->getNamedItemNS('', 'bar');
var_dump($a === null ? null : $a->nodeValue);
$b = $d->documentElement->attributes->getNamedItemNS('urn:q', 'bar');
var_dump($b === null ? null : $b->nodeValue);
$d2 = Dom\XMLDocument::createFromString('<root xmlns:q="urn:q" bar="no-ns" q:bar="ns"/>');
$a2 = $d2->documentElement->attributes->getNamedItemNS('', 'bar');
var_dump($a2 === null ? null : $a2->nodeValue);
var_dump($d2->documentElement->hasAttributeNS('', 'bar'));
$c = $d2->documentElement->attributes->getNamedItemNS('urn:q', 'bar');
var_dump($c === null ? null : $c->nodeValue);
?>
--EXPECT--
NULL
string(2) "ns"
string(5) "no-ns"
bool(true)
string(2) "ns"
Loading