From: cwood at austin dot rr dot com
Operating system: Mac OS X 10.2.8
PHP version: 5.0.0RC2
PHP Bug Type: SimpleXML related
Bug description: simplexml_load_string chokes on " "
Description:
------------
When trying to load a string containing an HTML-encoded
non-breaking space (" ") with
simplexml_load_string, I get the following warning:
Warning: Entity: line 14: error: Entity 'nbsp' not
defined in /Library/WebServer/Documents/simple.php on
line 11
But other HTML-escaped characters like > and <
make it through fine.
Reproduce code:
---------------
<?php
$xmlstr = <<<XML
<?xml version='1.0'?>
<rss>
<channel>
<item>
<title>This is the title</title>
<link>http://globelogger.com</link>
<description>This is the description</description>
</item>
</channel>
</rss>
XML;
$xml = simplexml_load_string(utf8_encode($xmlstr));
foreach($xml->channel->item as $item) {
echo "<b><a
href=".$item->link.">".$item->title."</a></b><br>".$item->description."<p>";
}
?>
Expected result:
----------------
<b><a href=http://globelogger.com>This is the title</
a></b><br>This is the description<p>
Actual result:
--------------
Warning: Entity: line 7: error: Entity 'nbsp' not
defined in /Library/WebServer/Documents/test.php on
line 15
Warning: This�is the description in /Library/
WebServer/Documents/test.php on line 15
Warning: ^ in /Library/
WebServer/Documents/test.php on line 15
Warning: Invalid argument supplied for foreach() in /
Library/WebServer/Documents/test.php on line 16
--
Edit bug report at http://bugs.php.net/?id=28339&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28339&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28339&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=28339&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=28339&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=28339&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=28339&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=28339&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=28339&r=support
Expected behavior: http://bugs.php.net/fix.php?id=28339&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=28339&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=28339&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=28339&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28339&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=28339&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=28339&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=28339&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28339&r=float