prohibit /, #, and + from unquoted strings

because the spec proposes syntactic meanings for these
This commit is contained in:
Havoc Pennington 2011-11-12 10:05:39 -05:00
parent be560731b8
commit 796937f3ac
3 changed files with 8 additions and 4 deletions

View File

@ -102,8 +102,8 @@ Different from JSON:
(details below)
- String values may sometimes omit quotes.
- Unquoted strings may not contain '$', '"', '{', '}',
'[', ']', ':', '=', ',', or '\' (backslash) and may not
contain whitespace (including newlines).
'[', ']', ':', '=', ',', '+', '#', '/' or '\' (backslash)
and may not contain whitespace (including newlines).
- Unquoted strings do not support any form of escaping; the
characters are all left as-is. If you need to use special
characters or escaping, you have to quote the string.

View File

@ -182,7 +182,7 @@ final class Tokenizer {
// chars JSON allows to be part of a number
static final String numberChars = "0123456789eE+-.";
// chars that stop an unquoted string
static final String notInUnquotedText = "$\"{}[]:=,\\";
static final String notInUnquotedText = "$\"{}[]:=,\\+#/";
// The rules here are intended to maximize convenience while
// avoiding confusion with real valid JSON. Basically anything

View File

@ -133,7 +133,11 @@ abstract trait TestUtils {
"""{ "a" : { "c" : 2 }, "b" : y${a}z }""", // trying to interpolate an object in a string
"""{ "a" : ${a} }""", // simple cycle
"""[ { "a" : 2, "b" : ${${a}} } ]""", // nested substitution
"[ = ]", // = is not a valid token
"[ = ]", // = is not a valid token in unquoted text
"[ + ]",
"[ / ]",
"[ # ]",
"[ \\ ]",
"{ include \"bar\" : 10 }", // include with a value after it
"{ include foo }", // include with unquoted string
"{ include : { \"a\" : 1 } }", // include used as unquoted key