Skip to content

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

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

[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.

Comment thread ext/dom/tests/modern/spec/NamedNodeMap_getNamedItemNS.phpt
@iliaal
iliaal force-pushed the fix/getnameditemns-empty-uri-84 branch from 9f8f9b4 to 9ffb828 Compare August 29, 2026 16:53
Comment thread ext/dom/namednodemap.c
Normalize an empty URI to NULL in spec-following mode so
xmlHasNsProp() matches null-namespace attributes, and skip
XML_ATTRIBUTE_DECL results which cannot be wrapped as nodes.

Closes phpGH-23498
@iliaal
iliaal force-pushed the fix/getnameditemns-empty-uri-84 branch from 9ffb828 to f6a7645 Compare August 30, 2026 14:11
@iliaal iliaal closed this in e832b5e Aug 30, 2026
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.

2 participants