From:             mike at opendns dot com
Operating system: Linux, debian sarge
PHP version:      5.1.6
PHP Bug Type:     Filesystem function related
Bug description:  fputcsv() fgetcsv() inconsistency odd number trailing 
backslashes

Description:
------------
If a string you write to a CSV file with fputcsv() ends with an _odd_
number of backslashes, then when you read it back in with fgetcsv(), it'll
miss the delimeter and combine two elements into one.

Reproduce code:
---------------
$tmp_file = '/tmp/csv_f_up.tmp';

$data_to_write = array('string ends with _odd_ number of backslashes
\\\\\\',"and isn't the last element");

echo "data_to_write:\n";
var_dump($data_to_write);

$h_w = fopen($tmp_file, 'w');
fputcsv($h_w, $data_to_write);
fclose($h_w);

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

echo "data_read_in:\n";
var_dump($data_read_in);

Expected result:
----------------
data_to_write:
array(2) {
  [0]=>
  string(48) "string ends with _odd_ number of backslashes \\\"
  [1]=>
  string(26) "and isn't the last element"
}
data_read_in:
array(2) {
  [0]=>
  string(48) "string ends with _odd_ number of backslashes \\\"
  [1]=>
  string(26) "and isn't the last element"
}
}

Actual result:
--------------
data_to_write:
array(2) {
  [0]=>
  string(48) "string ends with _odd_ number of backslashes \\\"
  [1]=>
  string(26) "and isn't the last element"
}
data_read_in:
array(1) {
  [0]=>
  string(77) "string ends with _odd_ number of backslashes \\\",and isn't
the last element""
}

-- 
Edit bug report at http://bugs.php.net/?id=38918&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38918&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38918&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38918&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=38918&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=38918&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=38918&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=38918&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=38918&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=38918&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=38918&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=38918&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=38918&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=38918&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38918&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=38918&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=38918&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=38918&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38918&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=38918&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=38918&r=mysqlcfg

Reply via email to