Skip to content

Commit

Permalink
reject empty array starting with comma in strict mode fixed gh-17
Browse files Browse the repository at this point in the history
  • Loading branch information
UrielCh committed Oct 28, 2015
1 parent 2503d67 commit cc10617
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ protected <T> T readArray(JsonReaderI<T> mapper) throws ParseException, IOExcept
throw new RuntimeException("Internal Error");
read();
boolean needData = false;
//
// special case needData is false and can close is true
if (c == ',' && !acceptUselessComma)
throw new ParseException(pos, ERROR_UNEXPECTED_CHAR, (char) c);
for (;;) {
switch (c) {
case ' ':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ public void testExcessiveComma3A() throws Exception {
MustThrows.testStrictInvalidJson(s, ParseException.ERROR_UNEXPECTED_CHAR);
JSONValue.parseWithException(s);
}

public void testExcessiveComma4A() throws Exception {
String s = "[,5]";
MustThrows.testStrictInvalidJson(s, ParseException.ERROR_UNEXPECTED_CHAR);
JSONValue.parseWithException(s);
}


public void testExcessiveComma1O() throws Exception {
String s = "{\"a\":1,,\"b\":1}";
Expand Down

0 comments on commit cc10617

Please sign in to comment.