Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100744 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93160 invoked from network); 22 Sep 2017 00:40:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Sep 2017 00:40:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=andreas@dqxtech.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=andreas@dqxtech.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dqxtech.net from 209.85.215.48 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.215.48 mail-lf0-f48.google.com Received: from [209.85.215.48] ([209.85.215.48:55439] helo=mail-lf0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/D8-62331-DEB54C95 for ; Thu, 21 Sep 2017 20:40:14 -0400 Received: by mail-lf0-f48.google.com with SMTP id u21so7241958lfk.12 for ; Thu, 21 Sep 2017 17:40:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ViAK/AUBWuYp8/t5UPpY+CPAnIwJW9qSYOIdR5i3aHQ=; b=FRDSrcXYSH6dEsBAN/AfYR02dG0ak+2EfwDYDTxGkpzKuAGpcb9IS31KUq0cu4Qf+Y EUzM4J+6knIQvgDD1vZzzXRyU0IGO8QFZ0YR75F3NyUpTNyDMrDwLj3dp400Lltbzq64 iLpA5oJjoKw5wgIU49+QvINpcn2g2V4PuclO2Zpsj/hZm7R7rdjvWPCaucT6vdK1nos+ 3JvzMBRGXfVwyn0LnnY6vh/hd1Aq9t6tR/7D0ybilj6Obx9mO1I9z4Y5KfHRuuA6dIPc DPmLqEv5O+GvegydFUXbkZR/bqAq5n9KyK8Bmfwmp3D5XT430u86+4Z6UcrGCoDQQ3yL JgOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ViAK/AUBWuYp8/t5UPpY+CPAnIwJW9qSYOIdR5i3aHQ=; b=pPHHNJvYzWVYVW+mMgziTB41VoDnAQOTgT223kQUaPeM80qtZCc5ON9pNcuTN2T6wa y6BVL0ANCFD3vvrBm8R2KFxu7uosscwXEXB9wnkWRt8asB7sUZcoEjLAt4nUtx7OAULT 4wNfy2FRViz/9yAS6nGNLviFmilzVRVXKE/dmqE2yGLBn3u7z/No7Z9tAUEIbvgDoL2x ajwLd65ZtY20KZSLTm9ZXiFDicBGh/H6gaiRkJueHvycQaJTSSAqmOQMdMhBG0JBJmXX 1NU4jsTaTxWLtTc6pBGCwE8YiUTVllUeHDHonNprUyWN/Whfwhz/PosRQMhZKgk4Ydcb qRvQ== X-Gm-Message-State: AHPjjUiEyb2HkttZP6uuChS20DVQ9MA9WWIrLO5PKGmAiiD/empHredf xSAChWcBNO3gLSSg66S3KzvH3JrT X-Received: by 10.25.80.26 with SMTP id e26mr1262697lfb.140.1506040810216; Thu, 21 Sep 2017 17:40:10 -0700 (PDT) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com. [209.85.215.52]) by smtp.googlemail.com with ESMTPSA id r2sm540624ljd.7.2017.09.21.17.40.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 17:40:09 -0700 (PDT) Received: by mail-lf0-f52.google.com with SMTP id m199so7281601lfe.3 for ; Thu, 21 Sep 2017 17:40:09 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDfNoE6iBH6HpfYvK4HGnPTHSYpcXV+aU0bln7N8GVR/ilZ/dW6E6NffSx8P980ss25VGCId6cm3Iy5y0wyfRo= X-Received: by 10.25.143.205 with SMTP id s74mr1517883lfk.236.1506040808958; Thu, 21 Sep 2017 17:40:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.212.79 with HTTP; Thu, 21 Sep 2017 17:39:48 -0700 (PDT) In-Reply-To: References: <7cf5adb8-0738-259e-6d1e-f966722fdae2@gmx.de> Date: Fri, 22 Sep 2017 02:39:48 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Dan Ackroyd Cc: "Christoph M. Becker" , PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] fputcsv() and $escape character From: andreas@dqxtech.net (Andreas Hennings) On Thu, Sep 21, 2017 at 11:08 PM, Dan Ackroyd wrote: > On 21 September 2017 at 12:43, Christoph M. Becker wrote: >> Hi everybody! >> >> 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. How so? What we can do: If $escape_char !== '', fputcsv() should work exactly as it does now. It can even use the same C code. If $escape_char === '', fputcsv() will have a different behavior than currently, where no character is treated as special. If we want to be 100% sure, these two cases can use completely separate C code, with one if() at the entry point. > > 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. Yeah why not. But it will require a lot more work and design decisions than just introducing a new allowed value for $enclosure parameter. > > 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. It can never be as fast as native functions. I vaguely remember something like factor 2 or 3 when I tried it, but for now treat this as hearsay. > > Touching the existing code is pretty certain to bring a lot of pain, > without resulting in a fully compliant csv parser/generator. > > cheers > Dan > Ack > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >