-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #80852: Stack-overflow when json_encode()'ing SimpleXMLElement
We ignore `XML_ENTITY_DECL` nodes when getting the hash of the properties of a `SimpleXMLElement`.
- Loading branch information
Showing
2 changed files
with
23 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--TEST-- | ||
Bug #80852 (Stack-overflow when json_encode()'ing SimpleXMLElement) | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('simplexml')) die('skip simplexml extension not available'); | ||
if (!extension_loaded('json')) die('skip json extension not available'); | ||
?> | ||
--FILE-- | ||
<?php | ||
$xml = '<!DOCTYPE foo [<!ENTITY xee1 "aaa"> <!ENTITY xee2 "&xee1;&xee1;"> ]><a>b&xee2;</a>'; | ||
$sxe = simplexml_load_string($xml); | ||
var_dump(json_encode($sxe)); | ||
var_dump($sxe); | ||
?> | ||
--EXPECT-- | ||
string(11) "{"xee2":{}}" | ||
object(SimpleXMLElement)#1 (1) { | ||
["xee2"]=> | ||
object(SimpleXMLElement)#3 (0) { | ||
} | ||
} |