php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55674 fgetcsv & str_getcsv skip empty fields in some tab-separated records
Submitted: 2011-09-12 16:42 UTC Modified: 2011-09-13 12:44 UTC
From: keith at iveys dot org Assigned: laruence (profile)
Status: Closed Package: Strings related
PHP Version: 5.3.8 OS: Linux (Centos 5.5)
Private report: No CVE-ID: None
 [2011-09-12 16:42 UTC] keith at iveys dot org
Description:
------------
If the record contains an (unquoted) empty field followed by a quoted field, the 
empty field is skipped, so all following column positions are off. This happens 
when the delimiter is "\t" but not when it's ",", so it probably has something to 
do with changes related to trimming whitespace. This problem seems to have been 
introduced between 5.3.6 and 5.3.8.

Test script:
---------------
$s = "0\t\t\"2\"\n";
$a = str_getcsv($s, "\t");
var_export($a);


Expected result:
----------------
array (
  0 => '0',
  1 => '',
  2 => '2',
)

Actual result:
--------------
array (
  0 => '0',
  1 => '2',
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-13 12:43 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&revision=316618
Log: Fixed Bug #55674 (fgetcsv & str_getcsv skip empty fields in some tab-separated records) which was introduced by r311543
 [2011-09-13 12:44 UTC] laruence@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: laruence
 [2011-09-13 12:44 UTC] laruence@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/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-04-18 09:48 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=84c94e29c9bb7c3b27d7b4fb41c599fb774f4faf
Log: Fixed Bug #55674 (fgetcsv & str_getcsv skip empty fields in some tab-separated records) which was introduced by r311543
 [2012-07-24 23:40 UTC] rasmus@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=84c94e29c9bb7c3b27d7b4fb41c599fb774f4faf
Log: Fixed Bug #55674 (fgetcsv & str_getcsv skip empty fields in some tab-separated records) which was introduced by r311543
 [2013-11-17 09:36 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=84c94e29c9bb7c3b27d7b4fb41c599fb774f4faf
Log: Fixed Bug #55674 (fgetcsv & str_getcsv skip empty fields in some tab-separated records) which was introduced by r311543
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC