[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6

From: Date: Fri, 27 Nov 2026 10:24:25 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-144254@lists.php.net to get a copy of this message
Author: Ilia Alshanetsky (iliaal) Date: 2026-11-27T05:18:50-05:00 Commit: https://github.com/php/php-src/commit/aee25b6240cc48fa0223c13b4b0a45ecdcedbe9e Raw diff: https://github.com/php/php-src/commit/aee25b6240cc48fa0223c13b4b0a45ecdcedbe9e.diff Merge branch 'PHP-8.5' into PHP-8.6 * PHP-8.5: ext/dom: Reject DTD declaration nodes in adoptNode() Changed paths: A ext/dom/tests/modern/spec/XMLDocument_adoptNode_dtd_declarations.phpt M NEWS M ext/dom/document.c Diff: diff --git a/NEWS b/NEWS index 05f79fcfac68..999d29afface 100644 --- a/NEWS +++ b/NEWS @@ -79,6 +79,8 @@ PHP NEWS node map iterator that has no current item. (Ilia Alshanetsky) . Fixed use-after-free in getElementById() after a removed ID attribute is freed. (Ilia Alshanetsky) + . Fixed bug GH-25750 (adoptNode() accepts DTD declaration nodes, which can + crash at document teardown). (Ian Mattas) - FFI: . Fixed bug GH-25558 (struct with an enum field passed by value is described diff --git a/ext/dom/document.c b/ext/dom/document.c index 427a8f5dc08a..fb86e9d5a8f9 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1208,6 +1208,9 @@ static void dom_document_adopt_node(INTERNAL_FUNCTION_PARAMETERS, bool modern) || nodep->type == XML_DOCUMENT_TYPE_NODE || nodep->type == XML_DTD_NODE || nodep->type == XML_ENTITY_NODE + || nodep->type == XML_ELEMENT_DECL + || nodep->type == XML_ATTRIBUTE_DECL + || nodep->type == XML_ENTITY_DECL || nodep->type == XML_NOTATION_NODE)) { php_dom_throw_error(NOT_SUPPORTED_ERR, dom_get_strict_error(dom_object_nodep->document)); RETURN_FALSE; diff --git a/ext/dom/tests/modern/spec/XMLDocument_adoptNode_dtd_declarations.phpt b/ext/dom/tests/modern/spec/XMLDocument_adoptNode_dtd_declarations.phpt new file mode 100644 index 000000000000..3ffa3dff7005 --- /dev/null +++ b/ext/dom/tests/modern/spec/XMLDocument_adoptNode_dtd_declarations.phpt @@ -0,0 +1,27 @@ +--TEST-- +Dom\Document::adoptNode() rejects DTD declarations +--EXTENSIONS-- +dom +--FILE-- +<?php +$xml = '<!DOCTYPE root [<!ELEMENT root EMPTY><!ENTITY ent "value">]><root/>'; +$source = Dom\XMLDocument::createFromString($xml); +$target = Dom\XMLDocument::createFromString('<target/>'); + +$nodes = [ + $source->doctype->childNodes->item(0), + $source->doctype->entities->item(0), +]; + +foreach ($nodes as $node) { + try { + $target->adoptNode($node); + echo "adopted\n"; + } catch (DOMException $e) { + echo $e::class, ": ", $e->getCode(), "\n"; + } +} +?> +--EXPECT-- +DOMException: 9 +DOMException: 9

« previous php.cvs (#144254) next »