Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79094 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44044 invoked from network); 21 Nov 2014 18:44:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Nov 2014 18:44:21 -0000 Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.15.19 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.15.19 mout.gmx.net Received: from [212.227.15.19] ([212.227.15.19:50646] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6A/53-26013-2088F645 for ; Fri, 21 Nov 2014 13:44:20 -0500 Received: from [192.168.0.100] ([91.67.244.80]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0MPlsg-1Xvknh3Nmk-004zPA; Fri, 21 Nov 2014 19:44:11 +0100 Message-ID: <546F8805.1050904@gmx.de> Date: Fri, 21 Nov 2014 19:44:21 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Tjerk Meesters CC: PHP Internals References: <82139FDD-8D8B-43D9-B811-ECC1FFE6E8A6@gmail.com> <546CC4C8.7010001@gmx.de> <8E49EAC8-3681-4E36-BDAD-163D292193DD@gmail.com> <546E2FA1.1010006@gmx.de> <058DB7FA-6A59-4FDD-BFF8-6430A0ED3674@gmail.com> In-Reply-To: <058DB7FA-6A59-4FDD-BFF8-6430A0ED3674@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:aT+cEOgo66ynO5RCqwET5mtltTiipY3Wq+YWBMHH+sZJRXhSINK dVdFyAnTxKdQkD0BRUMxTdBiAX8+wOtgKnD2/IS6Av4S8FySIcbecE8fGG1DZCgFB56IGu8 CHoSKsXuCXLmN9MthMa0uy5y95M9EBK1jbHH4w5nl/Mw/n6kvRIZJAbJrYAFsjHaMq/JffO POGYrA6uSJ6oMH44x5rkA== X-UI-Out-Filterresults: notjunk:1; Subject: Re: fgetcsv incompatible with fputcsv From: cmbecker69@gmx.de (Christoph Becker) Am 21.11.2014 um 02:53 schrieb Tjerk Meesters: >> On 21 Nov 2014, at 02:14, Christoph Becker wrote: >> >> Apparently, there is a somewhat hidden bug, see >> for a simplified test script. The expected result is >> >> string(14) ""a""b","a\""b"" >> >> or maybe >> >> string(14) ""a\"b","a\\"b"" >> >> The actual result makes no sense to me, even though str_getcsv() parses >> it "correctly”. > > That works exactly for the wrong reasons: > 1) upon seeing an escape character fgetcsv() will print that and the following character > 2) fputcsv() actually accepts an escape character too (despite what the documentation says) but treats it in the wrong way by not escaping that and the following character Ah, I see, thanks for the explanation. Apparently[1], the $escape parameter to fputcsv() has been added in PHP 5.5. I have made a respective edit at edit.php.net. BTW: wouldn't it be reasonable to also add the $escape parameter to SplFileObject::fputcsv()? For now one has to use SplFileObject::setCsvControl(). > The expected output, based on the given code should (imo) be: > > string(15) ""a\"b","a\\\"b"" > > Or: if the escape character is a double quote: > > string(15) “"a""b",”a\""b”” ACK. (Even though that would be a BC break.) > Unfortunately I can’t satisfy all the related bug reports, some decision of “correctness” needs to be made in the form of an RFC. ACK. Thanks for taking the time. :) [1] vs -- Christoph M. Becker