Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103287 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 44433 invoked from network); 30 Sep 2018 16:01:37 -0000 Received: from unknown (HELO mout.gmx.net) (212.227.15.15) by pb1.pair.com with SMTP; 30 Sep 2018 16:01:37 -0000 Received: from [192.168.2.136] ([91.8.166.159]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0McEI3-1gQB4m03Xz-00JYzZ; Sun, 30 Sep 2018 14:10:43 +0200 Received: from [192.168.2.136] ([91.8.166.159]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0McEI3-1gQB4m03Xz-00JYzZ; Sun, 30 Sep 2018 14:10:43 +0200 To: Nikita Popov Cc: PHP internals References: Message-ID: <7d095030-b4fa-9122-effa-07f187421935@gmx.de> Date: Sun, 30 Sep 2018 14:10:45 +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: 8bit X-Provags-ID: V03:K1:ZamsstN/FF+qOi8PREXhs7Jntc+i3SW8izk0MFbRDRh07snJUcT h2QqGAuncbRnFsBI2gcyjyAq36yyLqPawjUOK4tCioarGKnlGhhFoS+m73yzA5DDnsL0HFs VRNcKqcC2iQRNivNtv1bNI1dqDwexVCAZcyOc/bz6DnnsvZroDPEMPAdHRigAyvk/t3EOP8 zXZ8qqM1ah93YLww+q6tg== X-UI-Out-Filterresults: notjunk:1;V01:K0:4ffcQ/jUQuc=:S8dzH9tXBYKVcdmRpORRaT qe9wxahVGAU/+hGTvvw5aaaawhQpiWQTJTetk/GTeOt+mvuSj/sgsObijM5Vr4WOGYiXyetST POv3ThNI2Hx7qhLX+Kl/n07SxAJBHQMDfh60r1hw8rN3cZfi3oJnGhoirmLv8WnzVQiQguMUm RYNyRO4U2mMhfwH/MZuK2e6HlKv8RGV7ynN+DroUqWaWjjywYP/X9A4keNjoTXLOXcu8GaZqH hccnAYs6CLPJsFYqpLfPvesX8MZhD4ay0KRcYHJP2ztjKkIWwCsJPPgtHUNtVDbb2SEo4RulS Nqfa5jb2weQ1dRdjyNz4F+NHlzbwvLbC895VlExgbN3AmuKJIQVgJyqr23HQEAivmDZ8CDMSg HlggLz/8NyAbLiQTNeaZ4E8K/4zLTRWBVFGxUftcf7dvH+fDC2HuxKd80RtoOdGwxkEbS7tKX Xusbwvgj0dQfRi6Yle4rxshZ3jptQwvT5dnp27tqhFMsov9VK+JWDWZ6a386CywUaDae2rnug EOgL5pS6yZNFHlmBxWFCfj2nDHWCB+IOloeBYidu0wt4AiQD0LvWUCjSoZQRERFbR+s8mpD8K OC2Nchk20HnE0iHIMkxMzT2mazDKzIG6l4I1r5Ep9DeNSMJfon4bF0q5RKvgsqGqhdby4TW7L 6cUikIYZOAwUeFeMTaBPuAAM1SzUXbJu2Z0EBzs5KdCM5OCyTnAWG1jNiqeF4/SQQgiDXkS/R OQn9qGibjIIYDy1TPgcNq0zo7vyghrbZ5SiPIRYwnSwWAzJqbxDppxhXSTq7QnoVptqzg8yXh 0fXvp3/jRDwKgYsxpH3APVuJC7y1dLBjIIkKDKq6UYyTyXFbMk= Subject: Re: [PHP-DEV] [RFC] Kill proprietary CSV escaping mechanism From: cmbecker69@gmx.de ("Christoph M. Becker") On 30.09.2018 at 12:42, Nikita Popov wrote: > On Thu, Sep 27, 2018 at 12:29 PM Christoph M. Becker > wrote: > >> I hereby put the “Kill proprietary CSV escaping mechanism” under >> discussion: >> >> >> >> Any comments are welcome! > > Could you please add a description of how the escaping mechanism currently > works for read and write? My vague recollection is that the write and read > behavior actually have nothing to do with each other and the fputcsv > $escape parameter would be better described as the $corrupt parameter. We > may want to treat both cases in different ways. It's hard for me to describe something whose sense escapes me. How can two competing escaping mechanisms work at the same time? Anyhow, from looking at the implementation the write case (fputcsv)[1] is pretty clear: * if a field contains an escape character, it is enclosed with the enclosure character * if an enclosure character is preceeded by an escape character in a field, both are written verbatim (i.e. the enclosure character is not doubled) The implementation of the CSV reading[2] is way more complex, but appears to be broken anyway. For instance: $str = '"\\\\"a"'; print_r(str_getcsv($str)); outputs: Array ( [0] => \\a" ) Note that $str could have been produced by fputcsv($stream, ['\\\\"a']). [1] [2] -- Christoph M. Becker