php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26915 fgetcsv and quoted enclosures
Submitted: 2004-01-15 05:21 UTC Modified: 2004-01-15 05:35 UTC
From: juergen at henge-ernst dot de Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.3.4 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: juergen at henge-ernst dot de
New email:
PHP Version: OS:

 

 [2004-01-15 05:21 UTC] juergen at henge-ernst dot de
Description:
------------
The following line in a csv-file does not get parsed correctly:
"one\""one","two\\two","three""three","four\""four"

For me the csv format is defined as:
If a delimiter is used inside a string/entry, the entry must be enclosured with a character. If the encloure-character is used inside the entry, the enclosure character must be doubled.

maybe the fix of Bug #22382 "fgetcsv does not allow escaped quotes" introduced this behaviour.

With version 4.2.2, 4.2.3 the correct string is returned.

Reproduce code:
---------------
$str = '"one\""one","two\\\\two","three""three","four\""four"';
$x=fopen("x.csv","w");
fputs($x, $str);
fclose($x);
$x=fopen("x.csv","r");
while ($y=fgetcsv($x,1000,","))
 var_dump($y);


Expected result:
----------------
array(4) {
  [0]=>
  string(5) "one\"one"
  [1]=>
  string(8) "two\\two"
  [2]=>
  string(11) "three"three"
  [3]=>
  string(6) "four\"four"
}


Actual result:
--------------
array(4) {
  [0]=>
  string(5) "one\""
  [1]=>
  string(8) "two\\two"
  [2]=>
  string(11) "three"three"
  [3]=>
  string(6) "four\""
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-15 05:35 UTC] juergen at henge-ernst dot de
ok seems to be fixed in php4-STABLE-200401150830
PHP 4.3.5RC2-dev (cli)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC