Re: [Json] Leading and trailing whitespace

Carsten Bormann <cabo@tzi.org> Tue, 11 June 2013 05:15 UTC

Return-Path: <cabo@tzi.org>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id EFEE721F9AC5 for <json@ietfa.amsl.com>; Mon, 10 Jun 2013 22:15:24 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -106.131
X-Spam-Level:
X-Spam-Status: No, score=-106.131 tagged_above=-999 required=5 tests=[AWL=0.118, BAYES_00=-2.599, HELO_EQ_DE=0.35, RCVD_IN_DNSWL_MED=-4, USER_IN_WHITELIST=-100]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gOl012okI2Uo for <json@ietfa.amsl.com>; Mon, 10 Jun 2013 22:15:02 -0700 (PDT)
Received: from informatik.uni-bremen.de (mailhost.informatik.uni-bremen.de [IPv6:2001:638:708:30c9::12]) by ietfa.amsl.com (Postfix) with ESMTP id 5724C21F9AC4 for <json@ietf.org>; Mon, 10 Jun 2013 22:15:02 -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.4/8.14.4) with ESMTP id r5B5EQXu015692; Tue, 11 Jun 2013 07:14:27 +0200 (CEST)
Received: from [192.168.217.105] (p54893004.dip0.t-ipconnect.de [84.137.48.4]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by smtp-fb3.informatik.uni-bremen.de (Postfix) with ESMTPSA id 841323053; Tue, 11 Jun 2013 07:14:26 +0200 (CEST)
Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\))
Content-Type: text/plain; charset="iso-8859-1"
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <CAK3OfOiBmzCdQtyUFoBkSFMFJijE7K8eR+9YUv7bhD2YaQBW2Q@mail.gmail.com>
Date: Tue, 11 Jun 2013 07:14:25 +0200
Content-Transfer-Encoding: quoted-printable
Message-Id: <B0660BD8-5D82-4D35-BD0E-DC2212198C7B@tzi.org>
References: <06c101ce6625$0f891bf0$2e9b53d0$@augustcellars.com> <379266A1-82C1-4FF5-BD7C-EE657F1FD41F@vpnc.org> <06e901ce6638$e8f27a90$bad76fb0$@augustcellars.com> <51DE7E41-D682-4340-A234-7F7CFE513C10@vpnc.org> <070b01ce664b$e5e0ac10$b1a20430$@augustcellars.com> <6E03D281-D6BA-424D-A30A-3DA18E61A051@vpnc.org> <CAK3OfOiBmzCdQtyUFoBkSFMFJijE7K8eR+9YUv7bhD2YaQBW2Q@mail.gmail.com>
To: Nico Williams <nico@cryptonector.com>
X-Mailer: Apple Mail (2.1508)
Cc: Jim Schaad <ietf@augustcellars.com>, Paul Hoffman <paul.hoffman@vpnc.org>, json@ietf.org
Subject: Re: [Json] Leading and trailing whitespace
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.12
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: Tue, 11 Jun 2013 05:15:25 -0000

On Jun 11, 2013, at 05:42, Nico Williams <nico@cryptonector.com> wrote:

> Do implementations that allow any value type at the top-level allow
> leading and/or trailing whitespace?

Yes.  E.g.,

>> JSON.parse("\r\n \t 27 \r\n \t", quirks_mode: true)
=> 27

(quirks_mode is the flag that switches on the non-coforming acceptance of any "value".)

> *Should* they?

Yes.

(If you are not convinced from first principles: people have argued you can do streaming by adding whitespace, and that required being allowed to add whitespace :-)

So we will have to add a production:

	JSON-value = ws value ws

That didn't seem too hard.

Thanks for pointing this out, Jim.

This production can be in 4627-bis or in the document that defines the application/json-value media type, if we want to go the latter route.

Grüße, Carsten

PS.: Just to show that trailing whitespace is indeed properly parsed:
>> JSON.parse("\r\n \t 27 \r\n \t 28", quirks_mode: true)
JSON::ParserError: 795: unexpected token at '28'