|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-03-11 01:12 UTC] andrey at kostin dot info
Description:
------------
There are two xml files. The only difference between them is a one whitespace character in a row of ten whitespace characters. One file XMLReader processes with no problem, another one can't be read.
It works fine in PHP 5.5.35 for both files.
Test script:
---------------
<?php
$filename = 'bug1.xml';
$xml = new \XMLReader();
$xml->open($filename);
while ($xml->read()) {}
echo 'ok';
Expected result:
----------------
ok
Actual result:
--------------
PHP Warning: XMLReader::read(): /web/www/r24/r24.ua/bug1.xml:95: parser error : Input is not proper UTF-8, indicate encoding !
Bytes: 0xD1 0x85 0x2E 0x20 in /web/www/r24/r24.ua/bug.php on line 8
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 22 21:00:01 2025 UTC |
The following code doesn't work for both files in any PHP version (tested with 5.5.35 and 7.1.2): <?php $filename = 'test.xml'; $xml = fopen($filename, 'r'); $parser = xml_parser_create(); while ($data = fread($xml, 4096)) { xml_parse($parser, $data, feof($xml)); } echo xml_error_string(xml_get_error_code($parser)); xml_parser_free($parser); fclose($xml); And all files work fine with any script with any PHP version on Debian system. It looks like a bug in libxml2, not in PHP or XMLReader. Where should it be reported?