Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60908 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93728 invoked from network); 20 Jun 2012 22:21:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2012 22:21:53 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@googlemail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@googlemail.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:56977] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7C/EA-25489-00D42EF4 for ; Wed, 20 Jun 2012 18:21:53 -0400 Received: by obfk16 with SMTP id k16so5175879obf.29 for ; Wed, 20 Jun 2012 15:21:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=rHmyXRvyLjlbzfNljC0GckDt2+t+kqslnKVmTfe2D8w=; b=u7/AfbL4k7tZFy9zu/p/Kpagdp/TqIUELnkZuuhAYK0XKGt1DK4WsYH1kTvmyAZt3i eKwga0cGQ3NFWnegOqK0rdzBXhbQTdUIwQnT6OGoIMeMbR0JzYQAUizPZRMHz1bMNpED 9cL7iJkpC8T4T9tQA21YynQF1TmJLovS//7U0s4B36ceFJxPBFg08Q+TwhfwvQ+e6EwO alT2JL/IpApHVHc3nIfvrDkd9sGOd18qLmPPGjxV5FuVfY5QcU2pjuXslIL2JszHxtpY zlJLdcHyNpQysW7OgOTsuYcxMhyflhptPecCpPnTqWe0doDRkGRV/WHBrCyULRcOZoY9 8G1Q== MIME-Version: 1.0 Received: by 10.60.8.35 with SMTP id o3mr25317935oea.45.1340230910171; Wed, 20 Jun 2012 15:21:50 -0700 (PDT) Received: by 10.182.192.101 with HTTP; Wed, 20 Jun 2012 15:21:50 -0700 (PDT) Date: Thu, 21 Jun 2012 00:21:50 +0200 Message-ID: To: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: json_encode() behavior for incorrectly encoded strings From: nikita.ppv@googlemail.com (Nikita Popov) Hi internals! We currently have a big mess concerning the behavior of json_encode() with incorrectly encoded UTF-8 strings. To summarize the situation: PHP <= 5.3.13, PHP 5.4, master behave as follows when an invalid UTF-8 string is encountered: * The invalid string is replaced with "null", thus creating a partial JSON serialization * json_encode() returns the partial serialization, *not* false as it should * A warning is thrown, but only if display_errors=off * json_last_error() returns JSON_ERROR_UTF8 PHP 5.3.14 behaves as follows: * json_encode() returns false, as it should * A warning is thrown always, even with display_errors=on * json_last_error() returns JSON_ERROR_UTF8 * 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=on) appropriate without further discussion. 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 <= 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. Nikita