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.
Fix phpGH-16151: Assertion failure in ext/dom/parentnode/tree.c
Unfortunately, old DOM allows attributes to be used as parent nodes. Only text nodes and entities are allowed as children for these types of nodes, because that's the constraint DOM and libxml give us. Closes phpGH-16156.
- Loading branch information
Showing
3 changed files
with
72 additions
and
38 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,35 @@ | ||
--TEST-- | ||
GH-16151 (Assertion failure in ext/dom/parentnode/tree.c) | ||
--EXTENSIONS-- | ||
dom | ||
--FILE-- | ||
<?php | ||
|
||
$element = new DOMElement("N", "W", "y"); | ||
$attr = new DOMAttr("c" , "n"); | ||
$doc = new DOMDocument(); | ||
$doc->appendChild($element); | ||
$element->setAttributeNodeNS($attr); | ||
|
||
try { | ||
$attr->insertBefore(new DOMComment("h")); | ||
} catch (DOMException $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
try { | ||
$attr->appendChild(new DOMComment("h")); | ||
} catch (DOMException $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
|
||
$attr->insertBefore($doc->createEntityReference('amp')); | ||
$attr->appendChild($doc->createEntityReference('amp')); | ||
|
||
echo $doc->saveXML(); | ||
|
||
?> | ||
--EXPECT-- | ||
Hierarchy Request Error | ||
Hierarchy Request Error | ||
<?xml version="1.0"?> | ||
<N xmlns="y" c="n&&">W</N> |