#37617 [NEW]: Undeclared entity error
| From: | webmaster at freshtraxxx dot com | Date: | Sun, 28 May 2006 18:12:06 +0000 |
| Subject: | #37617 [NEW]: Undeclared entity error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-97704@lists.php.net to get a copy of this message | ||
From: webmaster at freshtraxxx dot com
Operating system: Windows XP Home
PHP version: 5CVS-2006-05-28 (snap)
PHP Bug Type: XML related
Bug description: Undeclared entity error
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
--
Edit bug report at http://bugs.php.net/?id=37617&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37617&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37617&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37617&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37617&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=37617&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37617&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37617&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37617&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37617&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37617&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=37617&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=37617&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37617&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37617&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37617&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37617&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37617&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37617&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37617&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37617&r=mysqlcfg