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

From: Date: Wed, 28 Oct 2026 03:18:42 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142865@lists.php.net to get a copy of this message
Author: David Carlier (devnexen) Date: 2026-10-28T03:15:21Z Commit: https://github.com/php/php-src/commit/d657f7a3c7be246d0c71e272cbf51ca52d48fbe7 Raw diff: https://github.com/php/php-src/commit/d657f7a3c7be246d0c71e272cbf51ca52d48fbe7.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: ext/dom: fix UAF on namespace axis results with foreign-doc XPath callback nodes # Conflicts: # ext/dom/xpath.c Changed paths: A ext/dom/tests/xpath_php_function_foreign_doc_namespace_axis.phpt M ext/dom/xpath.c Diff: diff --git a/ext/dom/tests/xpath_php_function_foreign_doc_namespace_axis.phpt b/ext/dom/tests/xpath_php_function_foreign_doc_namespace_axis.phpt new file mode 100644 index 000000000000..ad77a052d454 --- /dev/null +++ b/ext/dom/tests/xpath_php_function_foreign_doc_namespace_axis.phpt @@ -0,0 +1,36 @@ +--TEST-- +DOMXPath: namespace axis result on a node from a document created inside an XPath callback +--EXTENSIONS-- +dom +--FILE-- +<?php + +$doc = new DOMDocument; +$doc->loadXML('<root/>'); + +$xp = new DOMXPath($doc); +$xp->registerNamespace('my', 'my.ns'); +$xp->registerPHPFunctionNS('my.ns', 'include', function () { + $d = new DOMDocument; + $d->loadXML('<r><uaf xmlns:a="urn:a"/></r>'); + return $d->documentElement; +}); + +$result = $xp->query('my:include()/uaf/namespace::*'); +var_dump($result->length); +unset($xp); + +foreach ($result as $ns) { + var_dump($ns->nodeName, $ns->parentNode->nodeName); +} + +echo "Done\n"; + +?> +--EXPECT-- +int(2) +string(9) "xmlns:xml" +string(3) "uaf" +string(7) "xmlns:a" +string(3) "uaf" +Done diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 9199785b8138..8b8d162afcf3 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -404,7 +404,7 @@ static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type, bool modern) /* Make sure parent dom object exists, so we can take an extra reference. */ zval parent_zval; /* don't destroy me, my lifetime is transferred to the fake namespace decl */ - php_dom_create_object(nsparent, &parent_zval, &intern->dom); + php_dom_create_object(nsparent, &parent_zval, dom_xpath_intern_for_doc(intern, nsparent->doc)); dom_object *parent_intern = Z_DOMOBJ_P(&parent_zval); node = php_dom_create_fake_namespace_decl(nsparent, original, &child, parent_intern);

« previous php.cvs (#142865) next »