#50661 [Csd]: DOMDocument::loadXML does not allow UTF-16
ID: 50661
User updated by: geoffers+phpbugs at gmail dot com
Reported By: geoffers+phpbugs at gmail dot com
Status: Closed
Bug Type: DOM XML related
Operating System: Mac OS 10.5.8
PHP Version: 5.3SVN-2010-01-04 (SVN)
Assigned To: rrichards
New Comment:
Null-terminated strings and UTF-16
fun. :) Thanks for fixing it!
Previous Comments:
------------------------------------------------------------------------
[2010-01-06 13:16:36] rrichards@php.net
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
------------------------------------------------------------------------
[2010-01-06 13:13:18] svn@php.net
Automatic comment from SVN on behalf of rrichards
Revision: http://svn.php.net/viewvc/?view=revision&revision=293176
Log: fix bug #50661 (DOMDocument::loadXML does not allow UTF-16)
add test
------------------------------------------------------------------------
[2010-01-04 23:16:49] rrichards@php.net
Assign to self
------------------------------------------------------------------------
[2010-01-04 20:58:36] geoffers+phpbugs at gmail dot com
Description:
------------
DOMDocument::loadXML() does not support UTF-16 encoded XML. This breaks
the XML spec which says, "All XML processors MUST accept the UTF-8 and
UTF-16 encodings of Unicode". As such, DOMDocument::loadXML() is not a
conformant XML processor.
XMLReader supports this fine, which suggests something is wrong in the
use of the libxml2 API.
Reproduce code:
---------------
<?php
$data = "\xFE\xFF\x00\x3C\x00\x66\x00\x6F\x00\x6F\x00\x2F\x00\x3E";
$dom = new DOMDocument();
$dom->loadXML($data);
echo $dom->saveXML();
Expected result:
----------------
<?xml version="1.0"?>
<foo/>
Actual result:
--------------
PHP Warning: DOMDocument::loadXML(): Start tag expected, '<' not found
in Entity, line: 1 in /Users/gsnedders/Desktop/foo.php on line 5
Warning: DOMDocument::loadXML(): Start tag expected, '<' not found in
Entity, line: 1 in /Users/gsnedders/Desktop/foo.php on line 5
<?xml version="1.0"?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50661&edit=1
Thread (5 messages)