From: mike at opendns dot com Operating system: Linux, debian sarge PHP version: 5.2.1 PHP Bug Type: Filesystem function related Bug description: fgetcsv can't handle trailing odd number of backslashes
Description: ------------ 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. This was part of bug #39538. The other half of that bug was correctly fixed. This is still broken. Reproduce code: --------------- [EMAIL PROTECTED]:/tmp# cat -A csv.tmp "this element contains the delimiter, and ends with an odd number of backslashes (ex: 1)\",and it isn't the last element$ [EMAIL PROTECTED]:/tmp# cat test_csv.php <?php $file = '/tmp/csv.tmp'; $h = fopen($file, 'r'); $data = fgetcsv($h); fclose($h); var_dump($data); ?> Expected result: ---------------- [EMAIL PROTECTED]:/tmp# php test_csv.php array(2) { [0]=> string(88) "this element contains the delimiter, and ends with an odd number of backslashes (ex: 1)\" [1]=> string(29) "and it isn't the last element" } Actual result: -------------- [EMAIL PROTECTED]:/tmp# php test_csv.php array(1) { [0]=> string(120) "this element contains the delimiter, and ends with an odd number of backslashes (ex: 1)\",and it isn't the last element" } -- Edit bug report at http://bugs.php.net/?id=40501&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40501&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40501&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40501&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40501&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40501&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40501&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40501&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40501&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40501&r=support Expected behavior: http://bugs.php.net/fix.php?id=40501&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40501&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40501&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40501&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40501&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40501&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40501&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40501&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40501&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40501&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40501&r=mysqlcfg