mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix xinclude destruction of live attributes
This commit is contained in:
commit
2c45d67ad3
3 changed files with 33 additions and 7 deletions
1
NEWS
1
NEWS
|
@ -37,6 +37,7 @@ PHP NEWS
|
||||||
. Fix weird unpack behaviour in DOM. (nielsdos)
|
. Fix weird unpack behaviour in DOM. (nielsdos)
|
||||||
. Fixed bug GH-18090 (DOM: Svg attributes and tag names are being lowercased).
|
. Fixed bug GH-18090 (DOM: Svg attributes and tag names are being lowercased).
|
||||||
(nielsdos)
|
(nielsdos)
|
||||||
|
. Fix xinclude destruction of live attributes. (nielsdos)
|
||||||
|
|
||||||
- Fuzzer:
|
- Fuzzer:
|
||||||
. Fixed bug GH-18081 (Memory leaks in error paths of fuzzer SAPI).
|
. Fixed bug GH-18081 (Memory leaks in error paths of fuzzer SAPI).
|
||||||
|
|
|
@ -1669,14 +1669,28 @@ PHP_METHOD(Dom_XMLDocument, saveXml)
|
||||||
}
|
}
|
||||||
/* }}} end dom_document_savexml */
|
/* }}} end dom_document_savexml */
|
||||||
|
|
||||||
|
static void dom_xinclude_strip_references_for_attributes(xmlNodePtr basep)
|
||||||
|
{
|
||||||
|
for (xmlAttrPtr prop = basep->properties; prop; prop = prop->next) {
|
||||||
|
php_libxml_node_free_resource((xmlNodePtr) prop);
|
||||||
|
for (xmlNodePtr child = prop->children; child; child = child->next) {
|
||||||
|
php_libxml_node_free_resource(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void dom_xinclude_strip_references(xmlNodePtr basep)
|
static void dom_xinclude_strip_references(xmlNodePtr basep)
|
||||||
{
|
{
|
||||||
php_libxml_node_free_resource(basep);
|
php_libxml_node_free_resource(basep);
|
||||||
|
dom_xinclude_strip_references_for_attributes(basep);
|
||||||
|
|
||||||
xmlNodePtr current = basep->children;
|
xmlNodePtr current = basep->children;
|
||||||
|
|
||||||
while (current) {
|
while (current) {
|
||||||
php_libxml_node_free_resource(current);
|
php_libxml_node_free_resource(current);
|
||||||
|
if (current->type == XML_ELEMENT_NODE) {
|
||||||
|
dom_xinclude_strip_references_for_attributes(current);
|
||||||
|
}
|
||||||
current = php_dom_next_in_tree_order(current, basep);
|
current = php_dom_next_in_tree_order(current, basep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ $doc->loadXML(<<<XML
|
||||||
</xi:include>
|
</xi:include>
|
||||||
<xi:test xmlns:xi="http://www.w3.org/2001/XInclude">
|
<xi:test xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||||
<xi:include href="thisisnonexistent">
|
<xi:include href="thisisnonexistent">
|
||||||
<p>garbage</p>
|
<p attr="foo" attr2="bar">garbage</p>
|
||||||
</xi:include>
|
</xi:include>
|
||||||
</xi:test>
|
</xi:test>
|
||||||
</root>
|
</root>
|
||||||
|
@ -22,20 +22,31 @@ XML);
|
||||||
$xpath = new DOMXPath($doc);
|
$xpath = new DOMXPath($doc);
|
||||||
|
|
||||||
$garbage = [];
|
$garbage = [];
|
||||||
foreach ($xpath->query('//p') as $entry)
|
foreach ($xpath->query('//p') as $entry) {
|
||||||
$garbage[] = $entry;
|
$garbage[] = $entry;
|
||||||
|
foreach ($entry->attributes as $attr) {
|
||||||
|
$garbage[] = $attr;
|
||||||
|
foreach ($attr->childNodes as $child) {
|
||||||
|
$garbage[] = $child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@$doc->xinclude();
|
@$doc->xinclude();
|
||||||
|
|
||||||
foreach ($garbage as $node) {
|
foreach ($garbage as $node) {
|
||||||
try {
|
try {
|
||||||
var_dump($node->localName);
|
var_dump($node->localName);
|
||||||
} catch (DOMException $e) {
|
} catch (DOMException $e) {
|
||||||
echo $e->getMessage(), "\n";
|
echo $e->getMessage(), "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
Invalid State Error
|
Invalid State Error
|
||||||
Invalid State Error
|
Invalid State Error
|
||||||
Invalid State Error
|
Invalid State Error
|
||||||
|
Invalid State Error
|
||||||
|
Invalid State Error
|
||||||
|
Invalid State Error
|
||||||
|
Invalid State Error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue