diff --git a/NEWS b/NEWS index 336eb3b4331..4e2980908b1 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,8 @@ PHP NEWS (nielsdos) . Fix #77894 (DOMNode::C14N() very slow on generated DOMDocuments even after normalisation). (nielsdos) + . Revert changes to DOMAttr::$value and DOMAttr::$nodeValue expansion. + (nielsdos) - GD: . Removed imagerotate "ignore_transparent" argument since it has no effect. diff --git a/UPGRADING b/UPGRADING index a9de43fc0ca..5d06a74ce4b 100644 --- a/UPGRADING +++ b/UPGRADING @@ -44,10 +44,6 @@ PHP 8.3 UPGRADE NOTES . Static variable initializers can now contain arbitrary expressions. RFC: https://wiki.php.net/rfc/arbitrary_static_variable_initializers -- DOM: - . Assignment to DOMAttr::$value and DOMAttr::$nodeValue no longer expands - entities in the new value. - - FFI: . C functions that have a return type of void now return null instead of returning the following object object(FFI\CData:void) { } diff --git a/ext/dom/attr.c b/ext/dom/attr.c index 417f92a25c3..0a558a76642 100644 --- a/ext/dom/attr.c +++ b/ext/dom/attr.c @@ -148,8 +148,7 @@ int dom_attr_value_write(dom_object *obj, zval *newval) } dom_remove_all_children((xmlNodePtr) attrp); - xmlNodePtr node = xmlNewTextLen((xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str)); - xmlAddChild((xmlNodePtr) attrp, node); + xmlNodeSetContentLen((xmlNodePtr) attrp, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str)); zend_string_release_ex(str, 0); return SUCCESS; diff --git a/ext/dom/node.c b/ext/dom/node.c index 29262f85791..7fb45efc3af 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -178,9 +178,6 @@ int dom_node_node_value_write(dom_object *obj, zval *newval) /* Access to Element node is implemented as a convenience method */ switch (nodep->type) { case XML_ATTRIBUTE_NODE: - dom_remove_all_children(nodep); - xmlAddChild(nodep, xmlNewTextLen((xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str))); - break; case XML_ELEMENT_NODE: dom_remove_all_children(nodep); ZEND_FALLTHROUGH; diff --git a/ext/dom/tests/DOMAttr_entity_expansion.phpt b/ext/dom/tests/DOMAttr_entity_expansion.phpt deleted file mode 100644 index e3482d1a9d7..00000000000 --- a/ext/dom/tests/DOMAttr_entity_expansion.phpt +++ /dev/null @@ -1,54 +0,0 @@ ---TEST-- -DOMAttr entity expansion ---EXTENSIONS-- -dom ---FILE-- -createElement('elt'); -$doc->appendChild($elt); -$elt->setAttribute('a','&'); -print $doc->saveXML($elt) . "\n"; - -$attr = $elt->getAttributeNode('a'); -$attr->value = '&'; -print "$attr->value\n"; -print $doc->saveXML($elt) . "\n"; - -$attr->removeChild($attr->firstChild); -print $doc->saveXML($elt) . "\n"; - -$attr->nodeValue = '&'; -print "$attr->nodeValue\n"; -print $doc->saveXML($elt) . "\n"; - -$attr->nodeValue = '&'; -print "$attr->nodeValue\n"; -print $doc->saveXML($elt) . "\n"; - -$elt->removeAttributeNode($attr); -$elt->setAttributeNS('http://www.w3.org/2000/svg', 'svg:id','&'); -print $doc->saveXML($elt) . "\n"; - -$attr = $elt->getAttributeNodeNS('http://www.w3.org/2000/svg', 'id'); -$attr->value = '<&'; -print "$attr->value\n"; -print $doc->saveXML($elt) . "\n"; - -$node = new DOMAttr('foo','bar'); -$node->nodeValue = 'xx1yy'; -print "$node->nodeValue\n"; -?> ---EXPECT-- - -& - - -& - -& - - -<& - -xx1yy