#38427 [NEW]: unicode causes xml_parser to misbehave
| From: | codje2 at lboro dot ac dot uk | Date: | Fri, 11 Aug 2006 11:57:18 +0000 |
| Subject: | #38427 [NEW]: unicode causes xml_parser to misbehave | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-100692@lists.php.net to get a copy of this message | ||
From: codje2 at lboro dot ac dot uk
Operating system: OS X
PHP version: 5.1.4
PHP Bug Type: XML related
Bug description: unicode causes xml_parser to misbehave
Description:
------------
When xml_parse_into_struct reaches a unicode character (i.e an
umlaut) when in a CDATA array element.It will split the text
across two elements the second starting with that character.
Reproduce code:
---------------
<?php
header('Content-type: text/html; charset=utf-8');
$input=<<<END
<p>söme p tag <b>söme text</b> a bit more öf the p täg</p>
END;
print "<html><body><pre><xmp>";
//either save this example in UTF-8 form, or enable the follwing line
//$input=utf8_encode($input);
$parser = xml_parser_create('utf-8');
xml_parse_into_struct($parser, $input, $vals, $index);
print_r($vals);
print "</xmp></pre></body></html>";
?>
Expected result:
----------------
Array
(
[0] => Array
(
[tag] => P
[type] => open
[level] => 1
[value] => söme p tag
)
[1] => Array
(
[tag] => B
[type] => complete
[level] => 2
[value] => söme text
)
[2] => Array
(
[tag] => P
[value] => a bit more öf the p täg
[type] => cdata
[level] => 1
)
[4] => Array
(
[tag] => P
[type] => close
[level] => 1
)
)
Actual result:
--------------
Array
(
[0] => Array
(
[tag] => P
[type] => open
[level] => 1
[value] => söme p tag
)
[1] => Array
(
[tag] => B
[type] => complete
[level] => 2
[value] => söme text
)
[2] => Array
(
[tag] => P
[value] => a bit more
[type] => cdata
[level] => 1
)
[3] => Array
(
[tag] => P
[value] => öf the p täg
[type] => cdata
[level] => 1
)
[4] => Array
(
[tag] => P
[type] => close
[level] => 1
)
)
--
Edit bug report at http://bugs.php.net/?id=38427&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38427&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38427&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38427&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38427&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=38427&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38427&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38427&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38427&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38427&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38427&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=38427&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=38427&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38427&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38427&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38427&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38427&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38427&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38427&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38427&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38427&r=mysqlcfg