Bug #76940 [NEW]: fgetcsv not correctly parsing fputcsv output

From: Date: Thu, 27 Sep 2018 05:44:06 +0000
Subject: Bug #76940 [NEW]: fgetcsv not correctly parsing fputcsv output
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217253@lists.php.net to get a copy of this message
From: simon dot welsh at themarkagency dot com dot au Operating system: macOS + Linux PHP version: 7.3.0RC1 Package: *Directory/Filesystem functions Bug Type: Bug Bug description:fgetcsv not correctly parsing fputcsv output Description: ------------ When a value passed to fputcsv ends with the escape character, fgetcsv (and str_getcsv) do not correctly parse it. I'm not sure if this is an issue with fputcsv not escaping the escape character or fgetcsv not handling things properly. Test script: --------------- <?php $input = array(1, 3, '3\\', 5, 3); $f = fopen('php://temp,', 'w+'); fputcsv($f, $input); rewind($f); $output = stream_get_contents($f); rewind($f); var_dump($input, $output, str_getcsv($output), fgetcsv($f)); fclose($f); Expected result: ---------------- I expect $input and the results from str_getcsv and fgetcsv to be the same Actual result: -------------- The final three fields, including separators, are parsed as a single field. -- Edit bug report at https://bugs.php.net/bug.php?id=76940&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76940&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76940&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76940&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76940&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76940&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76940&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76940&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76940&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76940&r=support Expected behavior: https://bugs.php.net/fix.php?id=76940&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76940&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76940&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76940&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76940&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76940&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76940&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76940&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76940&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76940&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76940&r=mysqlcfg

« previous php.bugs (#217253) next »