Bug #78907 [Opn->Ver]: SplFileObject::fgetcsv() truncates data after CR char
Edit report at https://bugs.php.net/bug.php?id=78907&edit=1
ID: 78907
Updated by: cmb@php.net
Reported by: pandenitz at mail dot ru
Summary: SplFileObject::fgetcsv() truncates data after CR
char
-Status: Open
+Status: Verified
Type: Bug
Package: SPL related
Operating System: Ubuntu 16.0.4
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Firstly, this CSV is invalid, since any linebreaks inside a field
need to be enclosed in $enclosure characters. Also, you need to
set the READ_CSV flag. But even if that is done[1], the line is
still skipped. It works as expected with fgetcsv()[2], though.
[1] <https://3v4l.org/ga46S>
[2] <https://3v4l.org/Hg5TT>
Previous Comments:
------------------------------------------------------------------------
[2019-12-04 07:26:37] pandenitz at mail dot ru
Description:
------------
Tested on PHP 7.1.26 - 7.4.0
See https://3v4l.org/k1B5Y
The initial CSV file has CRLF line breaks.
4th row (starting from 0) has CR inside.
The parser truncates the chars after this CR and the line is incompletely parsed into an array.
Test script:
---------------
https://3v4l.org/k1B5Y
Expected result:
----------------
The row should be parsed correctly with an array element that contains CR inside because CRLF is the
real linebreak.
Actual result:
--------------
The row is truncated after CR.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78907&edit=1
Thread (6 messages)