Add test cases for invalid input

This commit is contained in:
John J. Aylward
2022-01-26 12:19:53 -05:00
parent f1b0210b8a
commit 7a124d857d
8 changed files with 1732 additions and 4 deletions

View File

@@ -209,6 +209,12 @@ public class JSONTokener {
this.previous = (char) c;
return this.previous;
}
/**
* Get the last character read from the input or '\0' if nothing has been read yet.
* @return the last character read from the input.
*/
protected char getPrevious() { return this.previous;}
/**
* Increments the internal indexes according to the previous character
@@ -428,10 +434,18 @@ public class JSONTokener {
return this.nextString(c);
case '{':
this.back();
return new JSONObject(this);
try {
return new JSONObject(this);
} catch (StackOverflowError e) {
throw new JSONException("JSON Array or Object depth too large to process.", e);
}
case '[':
this.back();
return new JSONArray(this);
try {
return new JSONArray(this);
} catch (StackOverflowError e) {
throw new JSONException("JSON Array or Object depth too large to process.", e);
}
}
/*