|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-09-24 13:51 UTC] tg_surf at hotmail dot com
Description: ------------ When trying to parse the following xml file I get an "Undeclared entity error" in PHP5. With PHP4 it works fine. Reproduce code: --------------- The code under "Example 3. External Entity Example" at http://www.php.net/manual/en/ref.xml.php with the following xml file: <?xml version="1.0"?> <!DOCTYPE rdf:RDF [ <!ENTITY test 'http://www.hpl.hp.com/semweb/2003/query_tester#'> <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'> ]> <rdf:RDF xmlns:rdf="&rdf;" xmlns="&test;"> <Test rdf:about="test1"> <description>RDFS reasoner: range test, wildcard</description> <tbox>rdfs/tbox1.rdf</tbox> <data>rdfs/data1.rdf</data> <query>rdfs/query-res.nt</query> <result>rdfs/result1.rdf</result> </Test> </rdf:RDF> Expected result: ---------------- <?xml version="1.0"?> <!DOCTYPE rdf:RDF [ <!ENTITY test 'http://www.hpl.hp.com/semweb/2003/query_tester#'> <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'> ]> <RDF:RDF XMLNS:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" XMLNS="http://www.hpl.hp.com/semweb/2003/query_tester#"> <TEST RDF:ABOUT="test1"> <DESCRIPTION>RDFS reasoner: range test, wildcard</DESCRIPTION> <TBOX>rdfs/tbox1.rdf</TBOX> <DATA>rdfs/data1.rdf</DATA> <QUERY>rdfs/query-res.nt</QUERY> <RESULT>rdfs/result1.rdf</RESULT> </TEST> </RDF:RDF> parse complete Actual result: -------------- &test;&rdf;&rdf;&test;XML error: Undeclared entity error at line 7 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
I tested this with a current snapshot (php5-win32-200411190730.zip), entities inside attributes are now reported correctly but entities in element content are silently ignored. Here is an example document that show this behaviour: <!DOCTYPE test [ <!ENTITY uuml "ü"> ]> <test t="ü">ü</test>Here is the complete script I used, with php5 (php5-win32-200411201530.zip) the entity is not resolved: <?php $xml = <<<HERE <!DOCTYPE test [ <!ENTITY uuml "ü"> ]> <test>ü</test> HERE; function characters($parser, $data) {print "data: $data\n";} $parser =& xml_parser_create('utf-8'); xml_set_character_data_handler($parser, 'characters'); if (!xml_parse($parser, $xml, true)) { echo xml_error_string(xml_get_error_code($parser)) . "\n"; } xml_parser_free($parser); ?> expected result (with php 4.3.8): data: ? actual result: nothing When using xml_parse_into_struct the entity is not expanded with php4 too, should I open another bug report for that?