Bug #76940 [Opn->Dup]: fgetcsv not correctly parsing fputcsv output

From: Date: Thu, 27 Sep 2018 08:56:23 +0000
Subject: Bug #76940 [Opn->Dup]: fgetcsv not correctly parsing fputcsv output
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217254@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76940&edit=1 ID: 76940 Updated by: cmb@php.net Reported by: simon dot welsh at themarkagency dot com dot au Summary: fgetcsv not correctly parsing fputcsv output -Status: Open +Status: Duplicate Type: Bug Package: *Directory/Filesystem functions Operating System: macOS + Linux PHP Version: 7.3.0RC1 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Basically a duplicate of bug #74713. As workaround you may be able to use "\0" as $escape parameter of fgetcsv() and fputcsv(). Previous Comments: ------------------------------------------------------------------------ [2018-09-27 05:44:06] simon dot welsh at themarkagency dot com dot au 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 this bug report at https://bugs.php.net/bug.php?id=76940&edit=1

« previous php.bugs (#217254) next »