Commit b1658ce3ba4 for php

commit b1658ce3ba4885c9fa5d1097ab93ceed31634eab
Author: lazerg <lazerg2@gmail.com>
Date:   Sun Dec 6 17:38:32 2026 +0500

    ext/dom: innerHTML on cloned Dom\HTMLDocument creates nameless attributes

    A document from cloneNode() has no name dictionary, and the HTML fragment
    bridge builds attribute names with xmlDictLookup(lxml_doc->dict, ...),
    which returns NULL for a NULL dictionary. Reading the attribute name or
    serializing it then crashes. The XML fragment path already creates a
    dictionary for the document when it has none, so the HTML path now does
    the same before converting the fragment.

    Fix GH-26109
    Close GH-26113

diff --git a/NEWS b/NEWS
index 4b0773e3a57..642cbdb591e 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP                                                                        NEWS
   . Fixed crash on memory limit error before a function saved its current
     opline. (Jorg Sowa)

+- DOM:
+  . Fixed bug GH-26109 (Setting innerHTML on an element of a cloned
+    Dom\HTMLDocument creates attributes without a name). (lazerg)
+
 - Enchant:
   . Fixed enchant_broker_set_dict_path() and enchant_broker_get_dict_path()
     returning null with libenchant 2. Both now return false. (lacatoire)
diff --git a/ext/dom/inner_html_mixin.c b/ext/dom/inner_html_mixin.c
index ef7f3051dc4..514a2300adc 100644
--- a/ext/dom/inner_html_mixin.c
+++ b/ext/dom/inner_html_mixin.c
@@ -208,6 +208,11 @@ static xmlNodePtr dom_html_fragment_parsing_algorithm(dom_object *obj, xmlNodePt
 	lxb_dom_node_t *node = dom_html_fragment_lexbor_parse(document, element, input);
 	xmlNodePtr fragment = NULL;
 	if (node != NULL) {
+		if (context_node->doc->dict == NULL) {
+			context_node->doc->dict = xmlDictCreate();
+			xmlDictSetLimit(context_node->doc->dict, XML_MAX_DICTIONARY_LIMIT);
+		}
+
 		/* node->last_child could be NULL, but that is allowed. */
 		lexbor_libxml2_bridge_status status = lexbor_libxml2_bridge_convert_fragment(node->last_child, context_node->doc, &fragment, true, true, is_template, php_dom_get_private_data(obj));
 		if (UNEXPECTED(status != LEXBOR_LIBXML2_BRIDGE_STATUS_OK)) {
diff --git a/ext/dom/tests/modern/html/interactions/gh26109.phpt b/ext/dom/tests/modern/html/interactions/gh26109.phpt
new file mode 100644
index 00000000000..6b33e76b664
--- /dev/null
+++ b/ext/dom/tests/modern/html/interactions/gh26109.phpt
@@ -0,0 +1,18 @@
+--TEST--
+GH-26109 (Setting innerHTML on an element of a cloned Dom\HTMLDocument creates attributes without a name)
+--EXTENSIONS--
+dom
+--CREDITS--
+joemax-o360
+--FILE--
+<?php
+$doc = Dom\HTMLDocument::createFromString('<!DOCTYPE html><html><body><p>x</p></body></html>', LIBXML_NOERROR);
+$copy = $doc->cloneNode(true);
+$div = $copy->createElement('div');
+$div->innerHTML = '<a href="#">t</a>';
+var_dump($div->firstChild->attributes->item(0)->name);
+var_dump($div->innerHTML);
+?>
+--EXPECT--
+string(4) "href"
+string(17) "<a href="#">t</a>"