Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29079 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89818 invoked by uid 1010); 27 Apr 2007 19:45:32 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 89800 invoked from network); 27 Apr 2007 19:45:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Apr 2007 19:45:32 -0000 Received: from [127.0.0.1] ([127.0.0.1:6795]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 41/47-29267-AD252364 for ; Fri, 27 Apr 2007 15:45:30 -0400 Authentication-Results: pb1.pair.com smtp.mail=tyler@n49.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=tyler@n49.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain n49.com from 69.20.65.106 cause and error) X-PHP-List-Original-Sender: tyler@n49.com X-Host-Fingerprint: 69.20.65.106 www.n49.com Linux 2.4/2.6 Received: from [69.20.65.106] ([69.20.65.106:41996] helo=server2.n49.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 24/F5-29267-58152364 for ; Fri, 27 Apr 2007 15:39:51 -0400 Received: from tyler (cmr-208-97-116-42.cr.net.cable.rogers.com [208.97.116.42]) by server2.n49.com (8.12.11.20060308/8.12.11) with ESMTP id l3RJdkQG025948 for ; Fri, 27 Apr 2007 15:39:46 -0400 Message-ID: <200704271939.l3RJdkQG025948@server2.n49.com> To: Date: Fri, 27 Apr 2007 15:39:34 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 Thread-Index: AceJA8hhjKgQdztmQqSSGM1m8iN+YQ== Subject: JSON ampersand patch From: tyler@n49.com ("Tyler Lawson") Hello, I hope this is the right place for this, as I'd like to post a patch for your consideration to the way the JSON handles ampersands. I have had problems sending JSON data back and forth over POST requests, where an ampersand separates variables. This patch will convert "&" into "\u0026", which will allow ampersands to travel freely and be parsed by any valid JSON decoder. This has been applied against php-5.2.1 --- json.c 2007-01-12 07:17:32.000000000 -0500 +++ my_json.c 2007-04-27 15:12:44.000000000 -0400 @@ -301,6 +301,11 @@ smart_str_appendl(buf, "\\t", 2); } break; + case '&': + { + smart_str_appendl(buf, "\\u0026", 6); + } + break; default: { if (us < ' ' || (us & 127) == us) Tyler