Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103145 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59744 invoked from network); 9 Sep 2018 18:51:54 -0000 Received: from unknown (HELO NAM04-SN1-obe.outbound.protection.outlook.com) (40.92.11.69) by pb1.pair.com with SMTP; 9 Sep 2018 18:51:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dxq5rw3OU9zOcgGgiMChZIpCQANEi3O5lyUopak6pvU=; b=FB0CfcMmM+P4z90BMK+AfDkrFqK5klkt60bGYieRFNzAHj/307Lz+f9GoklbqBPZRLGJVr2EuF2zwtHEqba/g1+tV5ju/KDi8iWFsfYFOmvju8HDDo1QgsaUcBHBuT8EVKz2ZJCumHmmlbb65TVa8ZbrK1oF1unDf03YggrWh0RB0ynrYHe+7hVqy9jlMT1maZuzB1ds08Vbz2e87uPLK0bpQ9QA413ATve//1Cz6OtNiLd6PxqkuoHGxZdMgfgMSaVOXLUDefXdCm/94QZFNPu8aSu2G6YSepyra/yOZrKCmjLfc2SxXVgmbp71GS4I4hKdtN2uNZ8fur7qcdwufw== Received: from SN1NAM04FT037.eop-NAM04.prod.protection.outlook.com (10.152.88.55) by SN1NAM04HT200.eop-NAM04.prod.protection.outlook.com (10.152.88.253) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.1122.11; Sun, 9 Sep 2018 14:55:47 +0000 Received: from CY4PR18MB1048.namprd18.prod.outlook.com (10.152.88.51) by SN1NAM04FT037.mail.protection.outlook.com (10.152.88.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.1143.11 via Frontend Transport; Sun, 9 Sep 2018 14:55:47 +0000 Received: from CY4PR18MB1048.namprd18.prod.outlook.com ([fe80::5840:aaff:8d9:dda]) by CY4PR18MB1048.namprd18.prod.outlook.com ([fe80::5840:aaff:8d9:dda%8]) with mapi id 15.20.1122.018; Sun, 9 Sep 2018 14:55:47 +0000 To: "Christoph M. Becker" , Dan Ackroyd CC: PHP internals Thread-Topic: [PHP-DEV] fputcsv() and $escape character Thread-Index: AQHTMs79wIy3YRpng0yJQdwP3Tm59aK/1eiAgAGjXoCCKLn9mA== Date: Sun, 9 Sep 2018 14:55:46 +0000 Message-ID: References: <7cf5adb8-0738-259e-6d1e-f966722fdae2@gmx.de> , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:ED9E82FB40F1E76E40BC01E5530C657121B66F95AFD4D4B20E055CD12DC400BB;UpperCasedChecksum:1270408BA2CA43D61C98EF77B2A89EDEC736184AB18BA794D736102ECB04C394;SizeAsReceived:7210;Count:47 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [6Y1/Jf0+ahv+gPsyuemQG0PrfnSYJ8HI] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;SN1NAM04HT200;6:moIWGhZ1sMQdcuAhijEIWR4YOmRW8p7JtTnMxAUtsqVhhVNEengibY6ofr0OVGBX73zNKSc8OmXkJa1clW9+9pUudB9vPYbo9h/BWOEqig7buRiBLNrH6rKG01jIhCsUAtR4O7Y9itKuQI2vNJBbjzDUvT5mA4iksokWp4UHcCTefn6Y21HAK35jyvQGAim2p0by5Bf1eMBufZViwoAE+Yq7PKUMI/3b0IROC6vMLOivuv6x9Ksrp+4XKCNNchXUldNOruwhaq4XPpTdBBVgRSCp7Lkjo5+xU/skivCvA6FD2m6qbL5hG1e0y6ilqQbOwX1OYg/ONLXShQUDjO8GQuo1WE3J/TfCQx6sYRS3xB5YnB+FQGMo3pot+AL/9gU5MQgdWYMg0pPE4ujrErnfRZ3nO4QXXOgQna16GND1lMU/TEIGGenl6JOnqQ6Vv+pzQnDWYfIxYeTyz9QTsaPZTw==;5:XY58GsoGHvI1FaENbDcWhZMUVtzOYq3F/d6ivFcBBxZFaUKmv1uqo2NGyfQb8OgOuHtdyrHib4ZbMi4Y/gMxzfmGb/MD+3HjCRcINKmqqPdrjsEdsMkcK5pxJF9CfKHnkAh7kFUPp7eMaKjLYJZ9jEotNBiyba1yVlduPKfHcb4=;7:PafwAyu2LIiCWbyxy/ZnySekGN891Q1t1FSndrIal8lwCiXqnrSBJWb8OoMzYCp83yJGXhLgo9/X7BBSMK2b6qnuw6Xdqzq8gRxlr67C5KsrjO1BKVfxD85maANG/eXiAk5lwDdyFWwvMO3EB33IAhYzJqHPrkvjiAtrbZ25h7K8zinpp7uXNbUoAlsx748ggmbq8ndbNBG4SQjzRggvVUqn5D3JbMMY4QLODpyHEIWe1IDxd8QWRCId+QlM0G3o x-incomingheadercount: 47 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1603101475)(1601125500)(1701031045);SRVR:SN1NAM04HT200; x-ms-traffictypediagnostic: SN1NAM04HT200: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(4566010)(82015058);SRVR:SN1NAM04HT200;BCL:0;PCL:0;RULEID:;SRVR:SN1NAM04HT200; x-forefront-prvs: 0790FB1F33 x-forefront-antispam-report: SFV:NSPM;SFS:(7070007)(189003)(199004)(14454004)(56003)(11346002)(86362001)(305945005)(256004)(486006)(476003)(6246003)(446003)(426003)(8936002)(8676002)(74316002)(6346003)(81156014)(102836004)(97736004)(110136005)(5660300001)(26005)(104016004)(229853002)(106356001)(105586002)(87572001)(20460500001)(55016002)(2900100001)(68736007)(5250100002)(966005)(99286004)(6436002)(25786009)(7696005)(33656002)(6306002)(4326008)(82202002)(76176011);DIR:OUT;SFP:1901;SCL:1;SRVR:SN1NAM04HT200;H:CY4PR18MB1048.namprd18.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: outlook.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=theodorejb@outlook.com; x-microsoft-antispam-message-info: tGQt0lCyILMIl15KE9EInZfF3NHNGasVZHZPZ7HLPnzJqkCkkyl85oCuh/fNnYSdKB1MEsS0Gw3TIcTJd6HnxzOUxBGB4l8kzsnBjHptNcJnMVLkVFAZFQ10KUcXj94uorNMKdSAGx6W6uEb+TE3wmInjUP2bPpa/vZe+JWdz7amoCsKwZ2TxW8Io9cniF+OkO0n/smokas+foBPd7Ynztq7PpxY8FArL3C6fCnYFZk= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: dd759f05-a917-4aa0-a2f5-4cc35c50e0c8 X-MS-Exchange-CrossTenant-Network-Message-Id: f51844c6-ec40-4676-3e69-08d61664535e X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: dd759f05-a917-4aa0-a2f5-4cc35c50e0c8 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Sep 2018 14:55:47.0099 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM04HT200 Subject: Re: [PHP-DEV] fputcsv() and $escape character From: theodorejb@outlook.com (Theodore Brown) On Friday, Sep. 22, 2017 at 5:09 PM Christoph M. Becker = wrote:=0A= =0A= >>> There are several bug reports regarding "broken" `fputcsv()` behavior= =0A= >>> in our tracker, namely, because the $escape parameter causes unexpected= =0A= >>> results. For instance:=0A= >>=0A= >> I looked at fixing some of the CSV related bugs about a year or so=0A= >> ago. My conclusions were:=0A= >>=0A= >> i) There is no way to fix the problems that wouldn't cause horrible BC= =0A= >> breaks for code that is only coincidentally working currently.=0A= >>=0A= >> ii) Handling strings in C is much more error prone than handling them in= PHP.=0A= >>=0A= >> I'm reasonably certain that trying to fix the current functions is the= =0A= >> wrong approach, and one of the following would be much better.=0A= >>=0A= >> Either, find a C library that has already been proven to handle CSV=0A= >> parsing/generating 'correctly' and bring that into PHP core under=0A= >> either new function names or namespace.=0A= >>=0A= >> Or, write the code in PHP (or just use https://github.com/thephpleague/c= sv)=0A= >> and find a way to make that fast enough for people to use.=0A= >>=0A= >> Touching the existing code is pretty certain to bring a lot of pain,=0A= >> without resulting in a fully compliant csv parser/generator.=0A= >=0A= > And frankly, I don't see why it would be a problem to allow to use no=0A= > escape character for `fputcsv()`. That certainly wouldn't be a BC break,= =0A= > since currently the function bails out if `escape_str_len < 1`. Of=0A= > course, that wouldn't fix all issues, but it appears to make the=0A= > function work as expected for ASCII compatible character encodings (for= =0A= > other character encodings the function appears to be broken anyway).=0A= > =0A= > Ad league/csv: rather impressive! However, including this functionality= =0A= > into ext/standard is totally over the top, in my opinion.=0A= =0A= Ironically, the League/Csv library uses `fputcsv()` behind the scenes, and= =0A= thus suffers from the same escape character problem=0A= (see https://github.com/thephpleague/csv/issues/307).=0A= =0A= Is there any chance `fputcsv()` can be updated to allow setting a blank=0A= string as the escape character? As Christopher pointed out, this would not= =0A= be a BC break, and while it wouldn't fix every issue with the function it= =0A= would still be a step forward. Frankly I found it very surprising that the= =0A= function *didn't* support passing a blank string.=0A= =0A= Thanks, =0A= Theodore Brown=