From: vasilyev at math dot uchicago dot edu Operating system: OS X (irrelevant) PHP version: 5.0.4 PHP Bug Type: Filesystem function related Bug description: fgetcsv incorrectly treats backslash
Description: ------------ This has been already mentioned in several bugs, that were all dismissed as bogus. Nevertheless, I believe there is a serious problem with the way fgetcsv treats backslash. Example: "a\","b" produces Array ( [0] => a\",b" ) [EMAIL PROTECTED] says that this is an expected behavior since backslash is an escaping character. Well, if this were true then "a\"b","c" would give Array ( [0] => a"b [1] => c ) while in fact you get Array ( [0] => a\"b [1] => c ) Another scenario: what do you do if you want to have a backslash at the end of a field (and let's say there are commas in that field, so we do have to use quotes). Well the natural answer is to escape the backslash: "a\\","b" but this would produce Array ( [0] => a\\ [1] => b ) It seems that the only thing a backslash does is making fgetcsv() not treat the following quote as an enclosure mark, without actually stripping the backslash. This is not escaping. There are two ways this can be fixed: 1.Make backslash an escaping character. This would further deviate fgetcsv() parsing of CSV files from the wide-spread understanding of what a CSV format is. 2.Treat backslash as any other character. I would prefer the second choice. -- Edit bug report at http://bugs.php.net/?id=33847&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33847&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33847&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33847&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33847&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33847&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33847&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33847&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33847&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33847&r=support Expected behavior: http://bugs.php.net/fix.php?id=33847&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33847&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33847&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33847&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33847&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33847&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33847&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33847&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33847&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33847&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33847&r=mysqlcfg