[php-src] Issue #11174: fgetcsv is not RFC4180 compliant

From: Date: Tue, 02 May 2023 06:37:48 +0000
Subject: [php-src] Issue #11174: fgetcsv is not RFC4180 compliant
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244322@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11174 Author: whiskeyfur ### Description The following code: ```php <?php $fp = fopen("test.csv", "r"); while (!feof($fp)) { print_r(fgetcsv($fp)); } ``` With this file (test.csv): ``` a,b,c,d,e,f 1,2,"3\","tt",55, "tt\" ``` Resulted in this output: ``` Array ( [0] => 1 [1] => 2 [2] => 3\",tt" [3] => 55 [4] => tt\" ) ``` But I expected this output instead: ``` Array ( [0] => 1 [1] => 2 [2] => 3\ [3] => tt [4] => 55 [5] => tt\ ) ``` in REC4180, the backslash is not the escape character. The only character that is escaped is the quote, and that is simply doubled up to escape it. This error exists all the way back to PHP 5.6 Tested with PHP 5.6.40, 7.2.34, 7.3.33, 7.4.30, 8.0.23 ### PHP Version PHP 8.0.23 ### Operating System _No response_

« previous php.bugs (#244322) next »