Skip to content

[DOM] fix getNamedItemNS() with empty URI not matching null namespace - #281

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

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

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Dom\NamedNodeMap::getNamedItemNS() passed the raw empty-string URI straight to xmlHasNsProp(), which only matches NULL-namespace attributes when the URI pointer is NULL, so getNamedItemNS("", "bar") returned NULL even though hasAttributeNS("", "bar") found the attribute in spec-following mode. This normalizes an empty URI to NULL at the namednodemap entry point, mirroring what dom_get_attribute_ns() already does in element.c, and adds a regression test covering both the legacy and Dom classes. Sibling audit of xmlHasNsProp() and xmlGetNsProp() call sites found no other paths that pass 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; sibling audit of xmlHasNsProp()/xmlGetNsProp() call sites
found no other user-supplied URI paths.
@iliaal iliaal closed this Aug 24, 2026
@iliaal iliaal reopened this Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant