ID:               39538
 Updated by:       [EMAIL PROTECTED]
 Reported By:      mike at opendns dot com
-Status:           Open
+Status:           Closed
 Bug Type:         *Directory/Filesystem functions
 Operating System: Linux, debian sarge
 PHP Version:      5.2.0
-Assigned To:      
+Assigned To:      dsp
 New Comment:

This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.

Fixed using a patch from David Soria Parra.


Previous Comments:
------------------------------------------------------------------------

[2006-11-16 20:48:29] mike at opendns dot com

Description:
------------
Two issues when reading in data from a CSV with fgetcsv():

If an element in a CSV file begins with a newline, fgetcsv() will think
there's two newlines there.

If an element in a CSV file ends with an odd number of trailing
backslashes, it'll miss the enclosure character.

This isn't a documentation problem -
http://www.rfc-editor.org/rfc/rfc4180.txt
Backslashes are not escape characters in CSV.

Reproduce code:
---------------
[EMAIL PROTECTED]:~$ cat -A /tmp/csv.tmp
"$
two seperate issues: string begins with a newline, ends with odd number
of backslashes \\\","and isnt the last element"$

[EMAIL PROTECTED]:~$ cat test_cvs.php
<?php
$tmp_file = '/tmp/csv.tmp';

$h = fopen($tmp_file, 'r');
$data_read_in = fgetcsv($h);
fclose($h);

var_dump($data_read_in);
?>

Expected result:
----------------
[EMAIL PROTECTED]:~$ php test_cvs.php
array(2) {
  [0]=>
  string(92) "
two seperate issues: string begins with a newline, ends with odd number
of backslasshes \\\"
  [1]=>
  string(25) "and isnt the last element"
}

Actual result:
--------------
[EMAIL PROTECTED]:~$ php test_cvs.php
array(1) {
  [0]=>
  string(121) "

two seperate issues: string begins with a newline, ends with odd number
of backslashes \\\",and isnt the last element""
}


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=39538&edit=1

Reply via email to