From: alexander dot varchenko at gmail dot com Operating system: FreeBSD,Linux,Windows PHP version: 5.2.5 PHP Bug Type: Filesystem function related Bug description: fgetcsv() enclosure
Description: ------------ Not every programs escapes enclosure characters, so it's should be good to check enclosures by delimiters chars start =delimiter+enclosure fin = enclosure+delimiter TEST data: test.csv [TSV] 1[tab]"NOAA "Official" Emergency"[tab]01/09/2008 2[tab]"Tories "reject" green" panel's advice"[tab]01/09/2008 Reproduce code: --------------- <? $handle = fopen('test.csv','rb'); $row = 1; while (($data = fgetcsv($handle, 1000, "\t",'"')) !== FALSE) { $num = count($data); echo "$num fields in line $row\n"; $row++; for ($c=0; $c < $num; $c++) { echo "[$c]:".$data[$c]."\n"; } } fclose($handle); ?> Expected result: ---------------- 3 fields in line 1 [0]:1 [1]:NOAA "Official" Emergency [2]:01/09/2008 3 fields in line 2 [0]:2 [1]:Tories "reject" green" panel's advice [2]:01/09/2008 Actual result: -------------- 4 fields in line 1 [0]:1 [1]:NOAA Official" Emergency" [2]:01/09/2008 4 fields in line 2 [0]:2 [1]:Tories reject" green" panel's advice" [2]:01/09/2008 -- Edit bug report at http://bugs.php.net/?id=43835&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43835&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43835&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43835&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43835&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43835&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43835&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43835&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43835&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43835&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43835&r=support Expected behavior: http://bugs.php.net/fix.php?id=43835&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43835&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43835&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43835&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43835&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43835&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43835&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43835&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43835&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43835&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43835&r=mysqlcfg