forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PHP-8.2: Fix phpGH-12616: DOM: Removing XMLNS namespace node results in invalid default: prefix Fix phpGH-12702: libxml2 2.12.0 issue building from src
- Loading branch information
Showing
6 changed files
with
333 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--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="http://symfony.com/schema/dic/services"> | ||
CHILDREN | ||
</container> | ||
XML | ||
); | ||
|
||
$doc->documentElement->removeAttributeNS('http://symfony.com/schema/dic/services', ''); | ||
echo $doc->saveXML(); | ||
|
||
$new = new DOMDocument(); | ||
$new->append( | ||
$new->importNode($doc->documentElement, true) | ||
); | ||
|
||
echo $new->saveXML(); | ||
|
||
?> | ||
--EXPECT-- | ||
<?xml version="1.0"?> | ||
<container> | ||
CHILDREN | ||
</container> | ||
<?xml version="1.0"?> | ||
<container> | ||
CHILDREN | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
--TEST-- | ||
GH-12616 (DOM: Removing XMLNS namespace node results in invalid default: prefix) | ||
--EXTENSIONS-- | ||
dom | ||
--FILE-- | ||
<?php | ||
|
||
$doc = new DOMDocument(); | ||
$doc->loadXML( | ||
<<<XML | ||
<container> | ||
<child1 xmlns:x="http://symfony.com/schema/dic/services"> | ||
<x:foo x:bar=""/> | ||
<x:foo x:bar=""/> | ||
</child1> | ||
<child2 xmlns:x="http://symfony.com/schema/dic/services"> | ||
<x:foo x:bar=""/> | ||
<x:foo x:bar=""/> | ||
</child2> | ||
</container> | ||
XML | ||
); | ||
|
||
$doc->documentElement->firstElementChild->removeAttributeNS('http://symfony.com/schema/dic/services', 'x'); | ||
echo $doc->saveXML(); | ||
|
||
$xpath = new DOMXPath($doc); | ||
|
||
echo "--- Namespaces of child1 ---\n"; | ||
|
||
foreach ($xpath->query("/container/child1/namespace::*") as $ns) { | ||
var_dump($ns); | ||
} | ||
|
||
echo "--- Namespaces of child1/foo (both nodes) ---\n"; | ||
|
||
foreach ($xpath->query("/container/child1/foo/namespace::*") as $ns) { | ||
var_dump($ns); | ||
} | ||
|
||
echo "--- Namespaces of child2 ---\n"; | ||
|
||
foreach ($xpath->query("/container/child2/namespace::*") as $ns) { | ||
var_dump($ns); | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
<?xml version="1.0"?> | ||
<container> | ||
<child1> | ||
<foo bar=""/> | ||
<foo bar=""/> | ||
</child1> | ||
<child2 xmlns:x="http://symfony.com/schema/dic/services"> | ||
<x:foo x:bar=""/> | ||
<x:foo x:bar=""/> | ||
</child2> | ||
</container> | ||
--- Namespaces of child1 --- | ||
object(DOMNameSpaceNode)#4 (10) { | ||
["nodeName"]=> | ||
string(9) "xmlns:xml" | ||
["nodeValue"]=> | ||
string(36) "http://www.w3.org/XML/1998/namespace" | ||
["nodeType"]=> | ||
int(18) | ||
["prefix"]=> | ||
string(3) "xml" | ||
["localName"]=> | ||
string(3) "xml" | ||
["namespaceURI"]=> | ||
string(36) "http://www.w3.org/XML/1998/namespace" | ||
["isConnected"]=> | ||
bool(true) | ||
["ownerDocument"]=> | ||
string(22) "(object value omitted)" | ||
["parentNode"]=> | ||
string(22) "(object value omitted)" | ||
["parentElement"]=> | ||
string(22) "(object value omitted)" | ||
} | ||
--- Namespaces of child1/foo (both nodes) --- | ||
object(DOMNameSpaceNode)#5 (10) { | ||
["nodeName"]=> | ||
string(9) "xmlns:xml" | ||
["nodeValue"]=> | ||
string(36) "http://www.w3.org/XML/1998/namespace" | ||
["nodeType"]=> | ||
int(18) | ||
["prefix"]=> | ||
string(3) "xml" | ||
["localName"]=> | ||
string(3) "xml" | ||
["namespaceURI"]=> | ||
string(36) "http://www.w3.org/XML/1998/namespace" | ||
["isConnected"]=> | ||
bool(true) | ||
["ownerDocument"]=> | ||
string(22) "(object value omitted)" | ||
["parentNode"]=> | ||
string(22) "(object value omitted)" | ||
["parentElement"]=> | ||
string(22) "(object value omitted)" | ||
} | ||
object(DOMNameSpaceNode)#8 (10) { | ||
["nodeName"]=> | ||
string(9) "xmlns:xml" | ||
["nodeValue"]=> | ||
string(36) "http://www.w3.org/XML/1998/namespace" | ||
["nodeType"]=> | ||
int(18) | ||
["prefix"]=> | ||
string(3) "xml" | ||
["localName"]=> | ||
string(3) "xml" | ||
["namespaceURI"]=> | ||
string(36) "http://www.w3.org/XML/1998/namespace" | ||
["isConnected"]=> | ||
bool(true) | ||
["ownerDocument"]=> | ||
string(22) "(object value omitted)" | ||
["parentNode"]=> | ||
string(22) "(object value omitted)" | ||
["parentElement"]=> | ||
string(22) "(object value omitted)" | ||
} | ||
--- Namespaces of child2 --- | ||
object(DOMNameSpaceNode)#9 (10) { | ||
["nodeName"]=> | ||
string(9) "xmlns:xml" | ||
["nodeValue"]=> | ||
string(36) "http://www.w3.org/XML/1998/namespace" | ||
["nodeType"]=> | ||
int(18) | ||
["prefix"]=> | ||
string(3) "xml" | ||
["localName"]=> | ||
string(3) "xml" | ||
["namespaceURI"]=> | ||
string(36) "http://www.w3.org/XML/1998/namespace" | ||
["isConnected"]=> | ||
bool(true) | ||
["ownerDocument"]=> | ||
string(22) "(object value omitted)" | ||
["parentNode"]=> | ||
string(22) "(object value omitted)" | ||
["parentElement"]=> | ||
string(22) "(object value omitted)" | ||
} | ||
object(DOMNameSpaceNode)#5 (10) { | ||
["nodeName"]=> | ||
string(7) "xmlns:x" | ||
["nodeValue"]=> | ||
string(38) "http://symfony.com/schema/dic/services" | ||
["nodeType"]=> | ||
int(18) | ||
["prefix"]=> | ||
string(1) "x" | ||
["localName"]=> | ||
string(1) "x" | ||
["namespaceURI"]=> | ||
string(38) "http://symfony.com/schema/dic/services" | ||
["isConnected"]=> | ||
bool(true) | ||
["ownerDocument"]=> | ||
string(22) "(object value omitted)" | ||
["parentNode"]=> | ||
string(22) "(object value omitted)" | ||
["parentElement"]=> | ||
string(22) "(object value omitted)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters