Re: [Json] Leading and trailing whitespace

Nico Williams <nico@cryptonector.com> Tue, 11 June 2013 06:08 UTC

Return-Path: <nico@cryptonector.com>
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 9797521F880F for <json@ietfa.amsl.com>; Mon, 10 Jun 2013 23:08:51 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.963
X-Spam-Level:
X-Spam-Status: No, score=-1.963 tagged_above=-999 required=5 tests=[AWL=0.014, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622]
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 EaRfwWol81DC for <json@ietfa.amsl.com>; Mon, 10 Jun 2013 23:08:46 -0700 (PDT)
Received: from homiemail-a55.g.dreamhost.com (caiajhbdcagg.dreamhost.com [208.97.132.66]) by ietfa.amsl.com (Postfix) with ESMTP id 9655021F8628 for <json@ietf.org>; Mon, 10 Jun 2013 23:08:46 -0700 (PDT)
Received: from homiemail-a55.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a55.g.dreamhost.com (Postfix) with ESMTP id D8CCA400FDB1F for <json@ietf.org>; Mon, 10 Jun 2013 23:08:45 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cryptonector.com; h= mime-version:in-reply-to:references:date:message-id:subject:from :to:cc:content-type:content-transfer-encoding; s= cryptonector.com; bh=EUazIsrR3+CcDreUTztDGvp4fhs=; b=t5z52gUC7Bu bkPfqF/S4Hv1ffdejYOkOOTeYoVU+WbeFZ5UXnR/cMpOdoFbHwxdYdPl8pCdA/4z HsIjXVSPZiY0dV8XWWJgf4F98F1QYWrUWtkIcsY8RNaEtweqwPZUYYnqqtLIkuge V53xEQQdWS7FnWKUMyoSyjfngDp74hHg=
Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: nico@cryptonector.com) by homiemail-a55.g.dreamhost.com (Postfix) with ESMTPSA id 8931F400FDB1E for <json@ietf.org>; Mon, 10 Jun 2013 23:08:45 -0700 (PDT)
Received: by mail-wg0-f45.google.com with SMTP id j13so201789wgh.12 for <json@ietf.org>; Mon, 10 Jun 2013 23:08:43 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=mXublk2A/G8kl0WEpeN7auUP/4rHVYcFFqLFEsN+964=; b=aw/u5QALaqDd6SeTkLv9IjKrxn3U4pDwiZgSYEYPMFsG4i5le7n8anJ0sMNWHSGog6 2y+4YEXciuR4i1SwL1vk9Kp/esV5YPDIyUFHQTtJwApvlTqD6+Ev9rOqgh0dABL+tybE tVQ7RvIkdffPnRfsCpRU5HoMwRC7KJ/ByK7KPHkf3RyI8mX19n6uV5PxdeTqyU5ZbrBp wm6cMplPnjatDc7WLISAqoHovj5sHzsLEPxEJJPk+Xl0vfB6fOrhHNUlrOojcEnoUnM2 qT7zz/irjBDKPigTm/d40CBYuma5SpZADBKAxFrUlzNqLPAImHgjl73AQ56+mOdNJtWb pZxw==
MIME-Version: 1.0
X-Received: by 10.180.90.164 with SMTP id bx4mr256132wib.13.1370930923949; Mon, 10 Jun 2013 23:08:43 -0700 (PDT)
Received: by 10.216.63.136 with HTTP; Mon, 10 Jun 2013 23:08:43 -0700 (PDT)
In-Reply-To: <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> <B0660BD8-5D82-4D35-BD0E-DC2212198C7B@tzi.org>
Date: Tue, 11 Jun 2013 01:08:43 -0500
Message-ID: <CAK3OfOirEygmtEnOpkOhWNUR8WmFvy_L=Pj8Xb1vEXuo+1wmJg@mail.gmail.com>
From: Nico Williams <nico@cryptonector.com>
To: Carsten Bormann <cabo@tzi.org>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
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 06:08:51 -0000

On Tue, Jun 11, 2013 at 12:14 AM, Carsten Bormann <cabo@tzi.org> wrote:
> 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".)

Right.  I suppose I meant "by default" :)

>> *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 :-)

Indeed, I've argued as much.  The whitespace is only needed to
distinguish end-of-message from a pemature EOF that might not
otherwise be understood as such.

> So we will have to add a production:
>
>         JSON-value = ws value ws
>
> That didn't seem too hard.

Do we need to remove whitespace elsewhere in the ABNF?  Or is
redundancy there OK?

> Thanks for pointing this out, Jim.

Yes, thanks!

> 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.

Sure.  For now I'm still arguing for allowing any value type at the top-level.

> 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'

Ah, good job.

Nico
--