Skip to content

ext/dom: resolve in-scope prefixed QName values during document valid…#22224

Open
devnexen wants to merge 2 commits into
php:PHP-8.4from
devnexen:gh22219-84
Open

ext/dom: resolve in-scope prefixed QName values during document valid…#22224
devnexen wants to merge 2 commits into
php:PHP-8.4from
devnexen:gh22219-84

Conversation

@devnexen

@devnexen devnexen commented Jun 4, 2026

Copy link
Copy Markdown
Member

…ation.

Fix #22219

Modern DOM keeps namespace declarations off the tree (node->nsDef is NULL), so libxml's native validators cannot resolve a prefixed QName appearing in element or attribute content. Temporarily materialize them as nsDef entries around schema, RelaxNG and DTD validation, reusing the C14N relink machinery, then restore the tree.

…ation.

Fix php#22219

Modern DOM keeps namespace declarations off the tree (node->nsDef is NULL),
so libxml's native validators cannot resolve a prefixed QName appearing in
element or attribute content. Temporarily materialize them as nsDef entries
around schema, RelaxNG and DTD validation, reusing the C14N relink
machinery, then restore the tree.
@devnexen devnexen marked this pull request as ready for review June 4, 2026 05:28
Comment thread ext/dom/namespace_compat.h Outdated
* that libxml's native validators/canonicalizers can resolve prefixed QNames that
* appear in element/attribute *content*. Modern DOM keeps declarations off the
* tree (node->nsDef == NULL), which xmlSearchNs() cannot follow. */
PHP_DOM_EXPORT void dom_relink_ns_decls(HashTable *links, xmlNodePtr root);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These shouldn't become public APIs imo. It would also not be acceptable in a stable release.
The idea of this PR itself is fine.

Comment thread ext/dom/node.c Outdated
}

static void dom_relink_ns_decls(HashTable *links, xmlNodePtr root)
void dom_relink_ns_decls(HashTable *links, xmlNodePtr root)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the namespace relinking may be moved to namespace_compat.c

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