Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60914 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27183 invoked from network); 21 Jun 2012 06:51:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jun 2012 06:51:41 -0000 Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vb0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:34010] helo=mail-vb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 83/22-09612-B74C2EF4 for ; Thu, 21 Jun 2012 02:51:39 -0400 Received: by vbbfs19 with SMTP id fs19so176460vbb.29 for ; Wed, 20 Jun 2012 23:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=GIrjf7dvuMEXyruRlT5/dbTZa2kglJVV8doao21MdoM=; b=0leUZeEwz5IaqSPp358mvjjOSZ5G2pEgZwqRBfDdGSYNBsDNnV8cg1Vf+IjRbFtwOp UnfPSvWjCc0bvMPEe6lFeXtTBiPoygkJ3QNse35c/JY39bDLxYBFjC8AbSINVj/UtV3r fB1x6c/xaPGOShMmV0fbezwrcJlq/6v6EQUGb7s66VvRm8IR8D8DP44o+hKRAsaDc+r0 MG7IG8S/CuqSkpCdvtSUPCxBPeHYLrdnmXVW6I/f7d7kFQXiYbzrwXzFjXL5aOe1ndTt X45/nnvy6ZKPlzhjMy3N0rprVLiKnX1EBWPii6LLyxCJ7a+RnjA9oPP0OKqRYXmS+c0Q jpzw== Received: by 10.52.176.66 with SMTP id cg2mr10698943vdc.121.1340261495947; Wed, 20 Jun 2012 23:51:35 -0700 (PDT) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.220.162.141 with HTTP; Wed, 20 Jun 2012 23:51:15 -0700 (PDT) In-Reply-To: References: Date: Thu, 21 Jun 2012 14:51:15 +0800 X-Google-Sender-Auth: qsHhuITwpPxpnYg6kg4nyPFl2KA Message-ID: To: Pierre Joye Cc: Nikita Popov , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] json_encode() behavior for incorrectly encoded strings From: laruence@php.net (Laruence) On Thu, Jun 21, 2012 at 2:47 PM, Pierre Joye wrote: > hi, > > On Thu, Jun 21, 2012 at 12:21 AM, Nikita Popov > wrote: > >> We currently have a big mess concerning the behavior of json_encode() >> with incorrectly encoded UTF-8 strings. >> >> To summarize the situation: >> >> PHP <=3D 5.3.13, PHP 5.4, master behave as follows when an invalid UTF-8 >> string is encountered: >> =C2=A0* The invalid string is replaced with "null", thus creating a part= ial >> JSON serialization >> =C2=A0* json_encode() returns the partial serialization, *not* false as = it should >> =C2=A0* A warning is thrown, but only if display_errors=3Doff >> =C2=A0* json_last_error() returns JSON_ERROR_UTF8 >> >> PHP 5.3.14 behaves as follows: >> =C2=A0* json_encode() returns false, as it should >> =C2=A0* A warning is thrown always, even with display_errors=3Don >> =C2=A0* json_last_error() returns JSON_ERROR_UTF8 >> =C2=A0* If the PHP_JSON_PARTIAL_OUTPUT_ON_ERROR option is specified, the >> old behavior is restored >> >> The reason for this situation is that a patch was applied for all >> branches, and then reverted, because Stas didn't consider the change >> towards always throwing a warning (even with display_errors=3Don) >> appropriate without further discussion. > > Well, not sure we have to discuss why such thing is bad. > display_errors must be respected. Agree, and it shall be, no any exception. thanks > > Also I suspect that this change should not even be merged in 5.4 nor > 5.3. At least not without real testing. > >> The backout though was done only on PHP 5.4 and master, but *not* on >> the PHP 5.3 branch. >> >> Thus we now have differing behavior between 5.3 and 5.4 (and PHP <=3D 5.= 3.13). >> >> So, I'd like to ask whether the patch can be reapplied to 5.4 and >> master or whether we should do something else to solve this problem. > > 5.3 should be brought in line with 5.4. > > Cheers, > -- > Pierre > > @pierrejoye | http://blog.thepimp.net | http://www.libgd.org > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --=20 Laruence =C2=A0Xinchen Hui http://www.laruence.com/