Re: [Json] Fixing the U+2028 and U+2029 problem

Carsten Bormann <cabo@tzi.org> Fri, 01 August 2014 23:58 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 331201A01EE for <json@ietfa.amsl.com>; Fri, 1 Aug 2014 16:58:54 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.551
X-Spam-Level:
X-Spam-Status: No, score=-1.551 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HELO_EQ_DE=0.35, SPF_HELO_PASS=-0.001] autolearn=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oOycsAmPO9Cx for <json@ietfa.amsl.com>; Fri, 1 Aug 2014 16:58:52 -0700 (PDT)
Received: from informatik.uni-bremen.de (mailhost.informatik.uni-bremen.de [IPv6:2001:638:708:30c9::12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 976EE1A01E5 for <json@ietf.org>; Fri, 1 Aug 2014 16:58:52 -0700 (PDT)
X-Virus-Scanned: amavisd-new at informatik.uni-bremen.de
Received: from smtp-fb3.informatik.uni-bremen.de (smtp-fb3.informatik.uni-bremen.de [134.102.224.120]) by informatik.uni-bremen.de (8.14.5/8.14.5) with ESMTP id s71Nwn29015446; Sat, 2 Aug 2014 01:58:49 +0200 (CEST)
Received: from [192.168.217.145] (p54892CA3.dip0.t-ipconnect.de [84.137.44.163]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by smtp-fb3.informatik.uni-bremen.de (Postfix) with ESMTPSA id 91EC2263; Sat, 2 Aug 2014 01:58:48 +0200 (CEST)
Content-Type: text/plain; charset="windows-1252"
Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <20140801211023.GI13476@mercury.ccil.org>
Date: Sat, 02 Aug 2014 01:58:46 +0200
X-Mao-Original-Outgoing-Id: 428630326.72736-b149278978b3523e0e90c4cc6ca0a0bc
Content-Transfer-Encoding: quoted-printable
Message-Id: <E280BCCD-7F02-4FCB-9E2C-562855E94CAF@tzi.org>
References: <20140801211023.GI13476@mercury.ccil.org>
To: John Cowan <cowan@mercury.ccil.org>
X-Mailer: Apple Mail (2.1878.6)
Archived-At: http://mailarchive.ietf.org/arch/msg/json/_X75pIePAUJeTyIPQjbLe7xs70M
Cc: json@ietf.org
Subject: Re: [Json] Fixing the U+2028 and U+2029 problem
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/json/>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 01 Aug 2014 23:58:54 -0000

On 01 Aug 2014, at 23:10, John Cowan <cowan@mercury.ccil.org> wrote:

> The unescaped characters U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH
> SEPARATOR) are valid in JSON strings, but illegal in JavaScript strings.
> It's too late to warn about this in RFC 7159, but can we get a requirement
> to escape these two characters into the definition of I-JSON, please?
> It's a minor gotcha, but still a gotcha.

I actually think it would be good to explicitly document this as a non-goal.  As in:

“Although JSON started out as a strict subset of the JavaScript language, changes to JavaScript have caused this to be no longer true.  There is no expectation that an I-JSON generator will restrict itself to a subset of modern JavaScript, specifically, there is no expectation that U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH
SEPARATOR) are escaped in strings.”

(Rationale: using JavaScript’s eval for decoding JSON is strongly discouraged.)

Grüße, Carsten