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 this is not your bug, you can add a comment by following this link.
If this is your bug, but 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

Add a Patch

Pull Requests

Add a Pull Request

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: Fri Mar 29 08:01:27 2024 UTC