From: juergen at henge-ernst dot de Operating system: PHP version: 4.3.4 PHP Bug Type: Filesystem function related Bug description: fgetcsv and quoted enclosures
Description: ------------ The following line in a csv-file does not get parsed correctly: "one\""one","two\\two","three""three","four\""four" For me the csv format is defined as: If a delimiter is used inside a string/entry, the entry must be enclosured with a character. If the encloure-character is used inside the entry, the enclosure character must be doubled. maybe the fix of Bug #22382 "fgetcsv does not allow escaped quotes" introduced this behaviour. With version 4.2.2, 4.2.3 the correct string is returned. Reproduce code: --------------- $str = '"one\""one","two\\\\two","three""three","four\""four"'; $x=fopen("x.csv","w"); fputs($x, $str); fclose($x); $x=fopen("x.csv","r"); while ($y=fgetcsv($x,1000,",")) var_dump($y); Expected result: ---------------- array(4) { [0]=> string(5) "one\"one" [1]=> string(8) "two\\two" [2]=> string(11) "three"three" [3]=> string(6) "four\"four" } Actual result: -------------- array(4) { [0]=> string(5) "one\"" [1]=> string(8) "two\\two" [2]=> string(11) "three"three" [3]=> string(6) "four\"" } -- Edit bug report at http://bugs.php.net/?id=26915&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26915&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26915&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26915&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26915&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26915&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=26915&r=needscript Try newer version: http://bugs.php.net/fix.php?id=26915&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=26915&r=support Expected behavior: http://bugs.php.net/fix.php?id=26915&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=26915&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=26915&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26915&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26915&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26915&r=dst IIS Stability: http://bugs.php.net/fix.php?id=26915&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=26915&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26915&r=float