fgetcsv & str_getcsv skip empty fields in some tab-separated records

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:44 UTC] laruence@php.net

-Status: Open +Status: Closed -Assigned To: +Assigned To: laruence