Revert changes to DOMAttr::$value and DOMAttr::$nodeValue expansion

Closes GH-11469.
This commit is contained in:
nielsdos 2023-06-19 19:52:28 +02:00
parent 12e4628815
commit ad5ee8a2b7
5 changed files with 3 additions and 63 deletions

2
NEWS
View File

@ -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.

View File

@ -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) { }

View File

@ -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;

View File

@ -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;

View File

@ -1,54 +0,0 @@
--TEST--
DOMAttr entity expansion
--EXTENSIONS--
dom
--FILE--
<?php
$doc = new DOMDocument;
$elt = $doc->createElement('elt');
$doc->appendChild($elt);
$elt->setAttribute('a','&');
print $doc->saveXML($elt) . "\n";
$attr = $elt->getAttributeNode('a');
$attr->value = '&amp;';
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 = '&amp;';
print "$attr->nodeValue\n";
print $doc->saveXML($elt) . "\n";
$elt->removeAttributeNode($attr);
$elt->setAttributeNS('http://www.w3.org/2000/svg', 'svg:id','&amp;');
print $doc->saveXML($elt) . "\n";
$attr = $elt->getAttributeNodeNS('http://www.w3.org/2000/svg', 'id');
$attr->value = '&lt;&amp;';
print "$attr->value\n";
print $doc->saveXML($elt) . "\n";
$node = new DOMAttr('foo','bar');
$node->nodeValue = 'xx&#x31;yy';
print "$node->nodeValue\n";
?>
--EXPECT--
<elt a="&amp;"/>
&amp;
<elt a="&amp;amp;"/>
<elt a=""/>
&
<elt a="&amp;"/>
&amp;
<elt a="&amp;amp;"/>
<elt xmlns:svg="http://www.w3.org/2000/svg" svg:id="&amp;amp;"/>
&lt;&amp;
<elt xmlns:svg="http://www.w3.org/2000/svg" svg:id="&amp;lt;&amp;amp;"/>
xx&#x31;yy