Bug #74236 [Opn->Nab]: XMLReader fails to read file

From: Date: Fri, 17 Mar 2017 12:02:02 +0000
Subject: Bug #74236 [Opn->Nab]: XMLReader fails to read file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207891@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 Updated by: cmb@php.net Reported by: andrey at kostin dot info Summary: XMLReader fails to read file -Status: Open +Status: Not a bug Type: Bug -Package: XML Reader +Package: XML related Operating System: Ubuntu 16.04 PHP Version: 7.1.2 -Assigned To: +Assigned To: cmb 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. Indeed, that might have been a bug in libxml2, but apparently it has been fixed, so I'm closing this ticket. Previous Comments: ------------------------------------------------------------------------ [2017-03-11 16:22:53] andrey at kostin dot info Upgraded libxml2 to 2.9.4 from Ubuntu 16.10 packages and everything works fine now. ------------------------------------------------------------------------ [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 (#207891) next »