Bug #74236 [Com]: XMLReader fails to read file

From: Date: Sat, 11 Mar 2017 16:22:54 +0000
Subject: Bug #74236 [Com]: XMLReader fails to read file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207783@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74236&edit=1 ID: 74236 Comment by: andrey at kostin dot info Reported by: andrey at kostin dot info Summary: XMLReader fails to read file Status: Open Type: Bug Package: XML Reader Operating System: Ubuntu 16.04 PHP Version: 7.1.2 Block user comment: N Private report: N New Comment: Upgraded libxml2 to 2.9.4 from Ubuntu 16.10 packages and everything works fine now. Previous Comments: ------------------------------------------------------------------------ [2017-03-11 15:18:27] andrey at kostin dot info 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? ------------------------------------------------------------------------ [2017-03-11 01:15:00] andrey at kostin dot info Links: https://kostin.info/bug1.xml https://kostin.info/bug2.xml ------------------------------------------------------------------------ [2017-03-11 01:12:50] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74236&edit=1

« previous php.bugs (#207783) next »