php-src/ext/dom/tests/replaceChild_attribute_validation.phpt
Niels Dossche 3ed01d454d
Add missing hierarchy checks to replaceChild
You can break the hierarchy for attribute nodes, use the helper function
introduced recently [1] to fix this issue.

[1] 066d18f2

Closes GH-16377.
2024-10-12 13:32:13 +02:00

27 lines
521 B
PHP

--TEST--
replaceChild with attribute children
--EXTENSIONS--
dom
--FILE--
<?php
$dom = new DOMDocument;
$attr = $dom->createAttribute('attr');
$attr->textContent = "test";
try {
$attr->replaceChild($dom->createProcessingInstruction('pi'), $attr->firstChild);
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
$root = $dom->appendChild($dom->createElement('root'));
$root->setAttributeNode($attr);
echo $dom->saveXML();
?>
--EXPECT--
Hierarchy Request Error
<?xml version="1.0"?>
<root attr="test"/>