Skip to content

Reject DTD declaration nodes in adoptNode - #25751

Closed
imattas wants to merge 2 commits into
php:PHP-8.4from
imattas:codex/ghsa-5357-dom-adopt-declarations
Closed

imattas wants to merge 2 commits into
php:PHP-8.4from
imattas:codex/ghsa-5357-dom-adopt-declarations

Conversation

@imattas

@imattas imattas commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Closes #25750\n\nReject XML_ELEMENT_DECL, XML_ATTRIBUTE_DECL, and XML_ENTITY_DECL nodes before cross-document adoption mutates libxml ownership. These DTD declarations remain owned by their source DTD; moving them can crash during document teardown.\n\nAdds a modern DOM regression test for element and entity declarations.\n\nTests (ASan build with libxml2 2.9.14):\n- ASAN_OPTIONS=detect_leaks=0 USE_ZEND_ALLOC=0 sapi/cli/php run-tests.php -q ext/dom/tests/modern/spec/XMLDocument_adoptNode_dtd_declarations.phpt\n- ASAN_OPTIONS=detect_leaks=0 USE_ZEND_ALLOC=0 sapi/cli/php run-tests.php -q ext/dom/tests/DOMDocument_adoptNode.phpt ext/dom/tests/modern/spec/XMLDocument_adoptNode_dtd_declarations.phpt\n\nBoth focused tests pass.

@imattas

imattas commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@devnexen merge ready?

?>
--EXPECT--
9
9 No newline at end of file

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.

there is a missing trailing newline.

@devnexen

Copy link
Copy Markdown
Member

@devnexen merge ready?

again wrong target branch

@imattas
imattas changed the base branch from master to PHP-8.4 November 25, 2026 20:32
@imattas
imattas requested a review from devnexen November 25, 2026 20:36
@imattas
imattas force-pushed the codex/ghsa-5357-dom-adopt-declarations branch from 2e49623 to 0fcc585 Compare November 25, 2026 20:39
@imattas imattas closed this Nov 25, 2026
@imattas
imattas deleted the codex/ghsa-5357-dom-adopt-declarations branch November 25, 2026 20:46
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.

Reject DTD declaration nodes in modern DOM adoptNode()

2 participants