-
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 #30875: xml_parse_into_struct() does not resolve entities
Setting up an empty default handler is not only useless, but actually harmful, since internal entity-references are not resolved anymore. From the libexpat docs[1]: | Setting the handler with this call has the side effect of | turning off expansion of references to internally defined general | entities. Instead these references are passed to the default | handler. [1] <https://www.xml.com/pub/1999/09/expat/reference.html#setdefhandler>
- Loading branch information
Showing
3 changed files
with
45 additions
and
1 deletion.
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,42 @@ | ||
--TEST-- | ||
Bug #30875 (xml_parse_into_struct() does not resolve entities) | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('xml')) die('skip xml extension not available'); | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
$xml = <<<XML | ||
<!DOCTYPE dtd [ | ||
<!ENTITY ref "ent"> | ||
]> | ||
<elt att="&ref;">a&ref;</elt> | ||
XML; | ||
|
||
$parser = xml_parser_create(); | ||
xml_parse_into_struct($parser, $xml, $vals); | ||
xml_parser_free($parser); | ||
var_dump($vals); | ||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
array(1) { | ||
[0]=> | ||
array(5) { | ||
["tag"]=> | ||
string(3) "ELT" | ||
["type"]=> | ||
string(8) "complete" | ||
["level"]=> | ||
int(1) | ||
["attributes"]=> | ||
array(1) { | ||
["ATT"]=> | ||
string(3) "ent" | ||
} | ||
["value"]=> | ||
string(4) "aent" | ||
} | ||
} | ||
===DONE=== |
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