Skip to content

[DOM] Fix getNamedItemNS() with empty URI not matching null namespace - #23498

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/getnameditemns-empty-uri-84
Open

[DOM] Fix getNamedItemNS() with empty URI not matching null namespace#23498
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/getnameditemns-empty-uri-84

Conversation

@iliaal

@iliaal iliaal commented Aug 29, 2026

Copy link
Copy Markdown
Member

Dom\NamedNodeMap::getNamedItemNS() passed an empty-string URI straight to xmlHasNsProp(), which matches NULL-namespace attributes only when the URI pointer is NULL, so getNamedItemNS("", "bar") returned NULL even though hasAttributeNS("", "bar") found the attribute in spec-following mode. An empty URI now normalizes to NULL at the namednodemap entry point when a base object is present, the same conversion dom_get_attribute_ns() applies in element.c. A sibling audit of xmlHasNsProp() and xmlGetNsProp() call sites found no other path passing a user-supplied URI.

Dom\\NamedNodeMap::getNamedItemNS() passed the raw empty-string URI to
xmlHasNsProp(), which only matches NULL-namespace attributes when the
URI pointer is NULL, so lookups like getNamedItemNS("", "bar") returned
NULL while hasAttributeNS("", "bar") found the attribute. Normalize an
empty URI to NULL in spec-following mode, mirroring dom_get_attribute_ns()
in element.c; skip the conversion when the map has no base object so
arginfo/zpp probes do not trip php_dom_follow_spec_intern(). Sibling
audit of xmlHasNsProp()/xmlGetNsProp() call sites found no other
user-supplied URI paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant