Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103156 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24968 invoked from network); 13 Sep 2018 16:26:01 -0000 Received: from unknown (HELO mout.gmx.net) (212.227.17.22) by pb1.pair.com with SMTP; 13 Sep 2018 16:26:01 -0000 Received: from [192.168.2.133] ([91.8.166.159]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0LjJCt-1fPzks3WLH-00dT1C; Thu, 13 Sep 2018 14:30:49 +0200 To: Theodore Brown , Dan Ackroyd Cc: PHP internals References: <7cf5adb8-0738-259e-6d1e-f966722fdae2@gmx.de> Message-ID: <5ca1b295-6f43-794c-f2a9-f672155cc84c@gmx.de> Date: Thu, 13 Sep 2018 14:30:50 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:Ac3mqTUYGxRujlSKjzO0iQWFj5yf3Gf6aPKBlqdXi8xVrht60iF v435C0Nb/59y1A/2ka/GssV48UWuSt6zFYoRWgBNXpiebPFqOyowB0KyspOtcmyrE1ZAwfk B7nNa5Y24219lNEdXX1Yfg+KZE3DzxCfdP7diLzy078wMyaZbluDy0zhf4EAReGxS+kbc31 8WYuGLJnPpnVpPVJLHtdg== X-UI-Out-Filterresults: notjunk:1;V01:K0:WjomND6h5qg=:DEt1ueBLTnvVx6PFmDqT2r OLfYPs0pdhJYfHJZcIGr5SjAWIFR5g8G/HP5hzzxi/i1gRxwSwFFpt7cG0kQfK3sKkPkYoLcT ql/aR8qDvTd3A4ja12ZC1cgGYgwuonC9O9qSyi8cbEabN9BG5ukunMKnHqDyrTNeyNjqZw2G4 maJXKPc95g1mghnL1TFRzsF5M49RT0zakS5WDLBTvmAO65295j9TN4Khq3EUiGKrhIFtoGgKw sWQYnihM0S0SJYPLMwhzGmpchYyCCi01ejZwBhDCWRYlCX8f6PBfhm3c4j++T3kyoRs74fast I+i6PUZ1fMJF0Y9aLmJKJ2UVuX1cLmBKvXse86Bh16UIhxldH/W98PzsOFSDh7P+rMyFKS9uG DmBnFfeULJcy/lC1j3PLWXGRF7RjaYncx6IlSr4LissBz8YxtwFFaKVl3NTKgY4x3qkuwiqxp 2CuMnV61dTGYgE+0K+EXTsZorzBk8ZLVwQ22WHKz5hOfHlF5zv897xFsKQCSrLbbpPtivnHEH NL1yI/nEBg2D5lsOSZ9D1BmBW7NqZwF0k1KcDqAyBezjN4xAlUb9+bxMcT/rZafbmz37t3sGU usaW7708nD/S2xuB4R6HIzScb6MMY/L7D98B3mNEy1HGzOUUx28FYyAjM0QI2EatXjWc24TRy 5We3MJ7I4wKJzuETyFSeaH7JWer9djz43nT+kc7fhXXNJ/smLrsAfHGhzCikqGpYiDAG13X6m JIW7j3XA+HvG45M5IYyhRjHsOvrIFKGRN6wsCvivsaPCnbhkNg0zBcqSQb6QWkN8m/8omt4z7 x2b4U9VEjQwnove05HDACRnJjtWoUhzApN3HxlgR0vAugXspUA= Subject: Re: [PHP-DEV] fputcsv() and $escape character From: cmbecker69@gmx.de ("Christoph M. Becker") On 09.09.2018 at 16:55, Theodore Brown wrote: > On Friday, Sep. 22, 2017 at 5:09 PM Christoph M. Becker wrote: > >>>> There are several bug reports regarding "broken" `fputcsv()` behavior >>>> in our tracker, namely, because the $escape parameter causes unexpected >>>> results. For instance: >>> >>> I looked at fixing some of the CSV related bugs about a year or so >>> ago. My conclusions were: >>> >>> i) There is no way to fix the problems that wouldn't cause horrible BC >>> breaks for code that is only coincidentally working currently. >>> >>> ii) Handling strings in C is much more error prone than handling them in PHP. >>> >>> I'm reasonably certain that trying to fix the current functions is the >>> wrong approach, and one of the following would be much better. >>> >>> Either, find a C library that has already been proven to handle CSV >>> parsing/generating 'correctly' and bring that into PHP core under >>> either new function names or namespace. >>> >>> Or, write the code in PHP (or just use https://github.com/thephpleague/csv) >>> and find a way to make that fast enough for people to use. >>> >>> Touching the existing code is pretty certain to bring a lot of pain, >>> without resulting in a fully compliant csv parser/generator. >> >> And frankly, I don't see why it would be a problem to allow to use no >> escape character for `fputcsv()`. That certainly wouldn't be a BC break, >> since currently the function bails out if `escape_str_len < 1`. Of >> course, that wouldn't fix all issues, but it appears to make the >> function work as expected for ASCII compatible character encodings (for >> other character encodings the function appears to be broken anyway). >> >> Ad league/csv: rather impressive! However, including this functionality >> into ext/standard is totally over the top, in my opinion. > > Ironically, the League/Csv library uses `fputcsv()` behind the scenes, and > thus suffers from the same escape character problem > (see https://github.com/thephpleague/csv/issues/307). > > Is there any chance `fputcsv()` can be updated to allow setting a blank > string as the escape character? As Christopher pointed out, this would not > be a BC break, and while it wouldn't fix every issue with the function it > would still be a step forward. Frankly I found it very surprising that the > function *didn't* support passing a blank string. I've submitted . -- Christoph M. Becker