Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73478 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62356 invoked from network); 29 Mar 2014 19:47:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Mar 2014 19:47:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=jakub.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jakub.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.48 as permitted sender) X-PHP-List-Original-Sender: jakub.php@gmail.com X-Host-Fingerprint: 209.85.216.48 mail-qa0-f48.google.com Received: from [209.85.216.48] ([209.85.216.48:40067] helo=mail-qa0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 57/10-60833-05327335 for ; Sat, 29 Mar 2014 14:47:29 -0500 Received: by mail-qa0-f48.google.com with SMTP id m5so6611747qaj.35 for ; Sat, 29 Mar 2014 12:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=h+zmLX0VqC7EJOvkE4vwyO+/hoAiX5C4lBe8YnSLxTg=; b=HYQsc1ukyEwo9OsDoN8vXJtinab+9dsI2uvDliWtz6d8QLzHVfrSEO5p2kVNytzSpg l8obzj5hpuTe93QD1Wlbwkf0dsmoacZ2WwXPYN7WUb2qeX8P5vQ+748Zyt5BpBm7PjSI lrNXzcF2RBLDOKWXsYT/QNizM9QyQSDvgAA4wbpLkRMRawVJkNkC2bz0x348Wu4/5WC7 +e10q6b4INnp0KBfUWoVIBTDHfr9XNK1O2FhlrKKQBH3ianf/KYGaZW+8JfPR+e6ExWq GH4AsJ7qr4JUpyb9RArUkZcBVKdGVTumFE1H0/lvpKKG/xbB1OCVeavqUc6JFQ8cQ1Ge ghdw== MIME-Version: 1.0 X-Received: by 10.224.43.200 with SMTP id x8mr17585332qae.43.1396122445956; Sat, 29 Mar 2014 12:47:25 -0700 (PDT) Sender: jakub.php@gmail.com Received: by 10.224.207.138 with HTTP; Sat, 29 Mar 2014 12:47:25 -0700 (PDT) Date: Sat, 29 Mar 2014 19:47:25 +0000 X-Google-Sender-Auth: Dbjuo4bEjplJQsdvjiY5QmYO2qk Message-ID: To: PHP internals list Content-Type: multipart/alternative; boundary=047d7bf0ec22744a0f04f5c416b0 Subject: JSON issues From: bukka@php.net (Jakub Zelenka) --047d7bf0ec22744a0f04f5c416b0 Content-Type: text/plain; charset=ISO-8859-1 Hi, I found few issues with the current ext/json during jsond testing: 1. The surrogate pairs for escaped Unicode characters are not handled correctly. For example JSON string "\uD811\uD811" (lead surrogate followed by lead surrogate) is accepted by the current implementation and converted to two ill-formatted UTF-8 characters. I would like to return NULL for such cases and set the new last json error code. I'm already using name JSON_ERROR_UTF16 for such case in jsond. If anyone thinks about better name, please let me know. This is apparently a bug but its fix require a new constant. I'm not sure about the version though. 5.6 only? 2. This is a valid JSON str: '{ "\u0000 key starting with zero": "value" }' . The problem is that it won't work when converted to stdClass as property name started with '\0' are used for mangled names. If you pass such string to json_decode, you will get a fatal error (the script is terminated). I would like to add a check to the JSON_Parser and return NULL from json_decode. It will requirea a new error code (new constant). Not sure about the name (any ideas welcomed) but it could be something like JSON_ERROR_MANGLED_PROPERTY_NAME. If user get such error, they can use assoc array (set second param for jsond_decode to true) and it will work. This should go to 5.6 as it's just an improvement that adds a new constant. 3. There is a small bug with number of digits when checking if it's a big number. The minus character is not considered for negative values which means that some really low numbers are considered as low even if they could be converted to long. It's a quick fix which should go to 5.4+ Any thoughts, comments or objections? Jakub --047d7bf0ec22744a0f04f5c416b0--