mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
3167d07603
The namespace data is freed and set to NULL, but there remain references to the namespace declaration nodes. This (rightfully) confuses libxml2 because its invariants are broken. We also have to remove all remaining references from the subtree. This fixes the data corruption bug. Closes GH-12681.
40 lines
887 B
PHP
40 lines
887 B
PHP
--TEST--
|
|
GH-12616 (DOM: Removing XMLNS namespace node results in invalid default: prefix)
|
|
--EXTENSIONS--
|
|
dom
|
|
--FILE--
|
|
<?php
|
|
|
|
$doc = new DOMDocument();
|
|
$doc->loadXML(
|
|
<<<XML
|
|
<container xmlns:test="urn:test" xmlns:symfony="http://symfony.com/schema/dic/services">
|
|
<symfony:services>
|
|
<test:service id="hello" />
|
|
</symfony:services>
|
|
</container>
|
|
XML
|
|
);
|
|
|
|
$doc->documentElement->removeAttributeNS('http://symfony.com/schema/dic/services', 'symfony');
|
|
$xpath = new DOMXPath($doc);
|
|
$xpath->registerNamespace('test', 'urn:test');
|
|
|
|
echo $doc->saveXML();
|
|
|
|
$result = $xpath->query('//container/services/test:service[@id="hello"]');
|
|
var_dump($result);
|
|
|
|
?>
|
|
--EXPECT--
|
|
<?xml version="1.0"?>
|
|
<container xmlns:test="urn:test">
|
|
<services>
|
|
<test:service id="hello"/>
|
|
</services>
|
|
</container>
|
|
object(DOMNodeList)#4 (1) {
|
|
["length"]=>
|
|
int(1)
|
|
}
|