Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60913 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25808 invoked from network); 21 Jun 2012 06:47:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jun 2012 06:47:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.170 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.161.170 mail-gg0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:46143] helo=mail-gg0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 45/D1-09612-683C2EF4 for ; Thu, 21 Jun 2012 02:47:34 -0400 Received: by ggnf2 with SMTP id f2so219214ggn.29 for ; Wed, 20 Jun 2012 23:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=oWulkswCBC1zTkNyeYiZtNUE2mzTfSKBIWwuT5jjH38=; b=g9bn7/Gd1VhkGJ3KYGUMRwDoefqLXG7+VLXG2DhuyrvP4nCwbnogoRpaosAgzinbp3 ln5QrqncokNjf1X52NEv3K+Y21Qox5P4bVAVF3p+DutIJnUksnnn3xujbT55UhCTpn+F aG6GyAPn/KMwKYk+wds82A8orIlSBjmIIrEJhYMPZ174cpW7peJ5RHxgT/btTYdeUJjb 5QqLEUAJRjk9CC1hY5X++55m3eoK8OQvjnrTySWdLwLJ5AoNK1lHefqt10xmAXD5/q6Q Br8fEfTKBiUOe2wrPORMXHYKSPPw/n91vtumBY8LL8Yz33+U7siSfSGdhBLSWguu+RNp V8Gw== MIME-Version: 1.0 Received: by 10.101.165.13 with SMTP id s13mr9458650ano.1.1340261251488; Wed, 20 Jun 2012 23:47:31 -0700 (PDT) Received: by 10.147.113.7 with HTTP; Wed, 20 Jun 2012 23:47:31 -0700 (PDT) In-Reply-To: References: Date: Thu, 21 Jun 2012 08:47:31 +0200 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] json_encode() behavior for incorrectly encoded strings From: pierre.php@gmail.com (Pierre Joye) 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: > =A0* The invalid string is replaced with "null", thus creating a partial > JSON serialization > =A0* json_encode() returns the partial serialization, *not* false as it s= hould > =A0* A warning is thrown, but only if display_errors=3Doff > =A0* json_last_error() returns JSON_ERROR_UTF8 > > PHP 5.3.14 behaves as follows: > =A0* json_encode() returns false, as it should > =A0* A warning is thrown always, even with display_errors=3Don > =A0* json_last_error() returns JSON_ERROR_UTF8 > =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. 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, --=20 Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org