Commit 98dc7aece4e for php
commit 98dc7aece4e8a1f108f2ac2c3832589cee3dc4a5
Author: imattas <ian@mattas.net>
Date: Thu Nov 26 04:56:09 2026 +0000
ext/dom: fix Dom\Notation publicId and systemId property handlers
The modern notation property table defines the publicId and systemId
virtual handlers, but the class registry pointed to the generic node
table. Reads fell through to standard property lookup and could crash
the process.
Fix GH-25752
Close GH-25754
diff --git a/NEWS b/NEWS
index 2f2d92d086f..7fd9ed3c6ac 100644
--- a/NEWS
+++ b/NEWS
@@ -67,6 +67,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-25752 (Reading Dom\Notation publicId or systemId can crash).
+ (Ian Mattas)
- FFI:
. Fixed bug GH-25558 (struct with an enum field passed by value is described
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index ed300185eec..76dbf9a3a3d 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -1249,7 +1249,7 @@ PHP_MINIT_FUNCTION(dom)
DOM_REGISTER_PROP_HANDLER(&dom_modern_notation_prop_handlers, "publicId", dom_notation_public_id_read, NULL);
DOM_REGISTER_PROP_HANDLER(&dom_modern_notation_prop_handlers, "systemId", dom_notation_system_id_read, NULL);
zend_hash_merge(&dom_modern_notation_prop_handlers, &dom_modern_node_prop_handlers, NULL, false);
- zend_hash_add_new_ptr(&classes, dom_modern_notation_class_entry->name, &dom_modern_node_prop_handlers);
+ zend_hash_add_new_ptr(&classes, dom_modern_notation_class_entry->name, &dom_modern_notation_prop_handlers);
dom_entity_class_entry = register_class_DOMEntity(dom_node_class_entry);
dom_entity_class_entry->create_object = dom_objects_new;
diff --git a/ext/dom/tests/modern/xml/DTDNamedNodeMap.phpt b/ext/dom/tests/modern/xml/DTDNamedNodeMap.phpt
index f9bb1f7a996..4f17f39e961 100644
--- a/ext/dom/tests/modern/xml/DTDNamedNodeMap.phpt
+++ b/ext/dom/tests/modern/xml/DTDNamedNodeMap.phpt
@@ -142,7 +142,11 @@
["textContent"]=>
NULL
}
-object(Dom\Notation)#4 (13) {
+object(Dom\Notation)#4 (15) {
+ ["publicId"]=>
+ string(0) ""
+ ["systemId"]=>
+ string(11) "viewgif.exe"
["nodeType"]=>
int(12)
["nodeName"]=>
diff --git a/ext/dom/tests/modern/xml/Notation_properties.phpt b/ext/dom/tests/modern/xml/Notation_properties.phpt
new file mode 100644
index 00000000000..0a07c1c3e6a
--- /dev/null
+++ b/ext/dom/tests/modern/xml/Notation_properties.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Dom\XMLDocument: Dom\Notation publicId and systemId properties
+--EXTENSIONS--
+dom
+--FILE--
+<?php
+$xml = <<<'XML'
+<!DOCTYPE r [
+ <!NOTATION image PUBLIC "-//Example//EN" "image.dat">
+ <!ELEMENT r EMPTY>
+]>
+<r/>
+XML;
+
+$doc = Dom\XMLDocument::createFromString($xml);
+$notation = $doc->doctype->notations->getNamedItem('image');
+
+var_dump($notation->publicId);
+var_dump($notation->systemId);
+?>
+--EXPECT--
+string(14) "-//Example//EN"
+string(9) "image.dat"