Req #35271 [Opn->Dup]: xml_parse_into_struct silently drops defined entities

From: Date: Wed, 14 Mar 2018 14:24:06 +0000
Subject: Req #35271 [Opn->Dup]: xml_parse_into_struct silently drops defined entities
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214353@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=35271&edit=1 ID: 35271 Updated by: cmb@php.net Reported by: bugs dot php dot net at nanonanonano dot net Summary: xml_parse_into_struct silently drops defined entities -Status: Open +Status: Duplicate Type: Feature/Change Request Package: XML related Operating System: Linux PHP Version: 4CVS-2005-11-18 (CVS) -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Duplicate of request #30875. Previous Comments: ------------------------------------------------------------------------ [2005-11-24 23:50:28] bugs dot php dot net at nanonanonano dot net This has been triaged to "Feature request" but it's a straight bug in the implementation: the docs claim that xml_parse_into_struct parses XML into a pair of arrays but the function doesn't do that. (at the very least, a warning should be in the documentation for xml_parse_into_struct that it will fubar your data if you have entities in it, but I'd obviously prefer that the function just worked properly) ------------------------------------------------------------------------ [2005-11-18 07:17:00] bugs dot php dot net at nanonanonano dot net Description: ------------ When called on an XML document that contains defined entities, xml_parse_into_struct silently drops the entities from the parsed output. (If the entity is undefined, it returns an error) Reproduce code: --------------- <?php $data = implode ("", file('entityexample.xml')); $parser = xml_parser_create(); xml_parser_set_option ($parser,XML_OPTION_CASE_FOLDING,0); xml_parser_set_option ($parser,XML_OPTION_SKIP_WHITE,1); xml_parse_into_struct ($parser,$data,$values,$tags); xml_parser_free ($parser); #echo "VALS\n"; print_r($values); #echo "TAGS\n"; print_r($tags); echo $values[2]['value']."\n"; ?> ---------- entityexample.xml -------------- <?xml version='1.0'?> <!DOCTYPE test [ <!ENTITY times "FOO BAR"> ]> <test> <item> <name>One &times; two</name> </item> </test> Expected result: ---------------- The entity should either be not replaced: One &times; two or it should be correctly replaced: One FOO BAR two Actual result: -------------- The entity is silently dropped from the XML stream: One two ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=35271&edit=1

« previous php.bugs (#214353) next »