[php-src] master: ext/dom: fix Dom\Notation publicId and systemId property handlers
| From: | imattas via David Carlier | Date: | Thu, 26 Nov 2026 05:00:39 +0000 |
| Subject: | [php-src] master: ext/dom: fix Dom\Notation publicId and systemId property handlers | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-144200@lists.php.net to get a copy of this message | ||
Author: imattas (imattas)
Committer: David Carlier (devnexen)
Date: 2026-11-26T04:56:09Z
Commit: https://github.com/php/php-src/commit/98dc7aece4e8a1f108f2ac2c3832589cee3dc4a5
Raw diff: https://github.com/php/php-src/commit/98dc7aece4e8a1f108f2ac2c3832589cee3dc4a5.diff
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
Changed paths:
A ext/dom/tests/modern/xml/Notation_properties.phpt
M NEWS
M ext/dom/php_dom.c
M ext/dom/tests/modern/xml/DTDNamedNodeMap.phpt
Diff:
diff --git a/NEWS b/NEWS
index 2f2d92d086f1..7fd9ed3c6ac7 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 ed300185eec1..76dbf9a3a3d7 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 f9bb1f7a996e..4f17f39e9612 100644
--- a/ext/dom/tests/modern/xml/DTDNamedNodeMap.phpt
+++ b/ext/dom/tests/modern/xml/DTDNamedNodeMap.phpt
@@ -142,7 +142,11 @@ object(Dom\Entity)#3 (17) {
["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 000000000000..0a07c1c3e6a7
--- /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"