php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37617 Undeclared entity error
Submitted: 2006-05-28 18:12 UTC Modified: 2006-06-01 09:56 UTC
From: webmaster at freshtraxxx dot com Assigned:
Status: Not a bug Package: XML related
PHP Version: 5CVS-2006-05-28 (snap) OS: Windows XP Home
Private report: No CVE-ID: None
 [2006-05-28 18:12 UTC] webmaster at freshtraxxx dot com
Description:
------------
Error results when trying to parse an rdf news feed with the listed doctype element. Although this is similar to previous bugs it still seems to be happening with the latest version.

I have a workaround that stripps out the offending lines until this is fixed:

preg_match("/<rdf:RDF(.*?)>(.*?)<\/rdf:RDF>/s",$output,$match);
if($match[0]) {
	$output = $match[0];
}


Reproduce code:
---------------
// functions "startElement", "endElement" and "characterData" stripped out for clarity

$output = <<<EOF
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">
%HTMLlat1;
]>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
</rdf:RDF>
EOF;

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!xml_parse($xml_parser, $output, true)) {
	die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
}
xml_parser_free($xml_parser);


Expected result:
----------------
Expected no output in above script as the handler functions only output cdata from within the rdf elements

Actual result:
--------------
XML error: Undeclared entity error at line 5

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-01 09:56 UTC] tony2001@php.net
If libxml fails to parse your file PHP can't do anything about it.
Not PHP problem.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 06:01:35 2024 UTC