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 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, the same conversion dom_get_attribute_ns() applies in element.c, and a regression test covers the legacy and Dom classes. 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; 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