| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -256,6 +256,9 @@ public JSONObject(JSONTokener x) throws JSONException { | |||
| 256 | 256 | if (x.nextClean() == '}') { | |
| 257 | 257 | return; | |
| 258 | 258 | } | |
| 259 | + if (x.end()) { | ||
| 260 | + throw x.syntaxError("A JSONObject text must end with '}'"); | ||
| 261 | + } | ||
| 259 | 262 | x.back(); | |
| 260 | 263 | break; | |
| 261 | 264 | case '}': | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2225,6 +2225,15 @@ public void jsonObjectParsingErrors() { | |||
| 2225 | 2225 | "Expected a ',' or '}' at 15 [character 16 line 1]", | |
| 2226 | 2226 | e.getMessage()); | |
| 2227 | 2227 | } | |
| 2228 | + try { | ||
| 2229 | + // \0 after , | ||
| 2230 | + String str = "{\"myKey\":true, \0\"myOtherKey\":false}"; | ||
| 2231 | + assertNull("Expected an exception",new JSONObject(str)); | ||
| 2232 | + } catch (JSONException e) { | ||
| 2233 | + assertEquals("Expecting an exception message", | ||
| 2234 | + "A JSONObject text must end with '}' at 15 [character 16 line 1]", | ||
| 2235 | + e.getMessage()); | ||
| 2236 | + } | ||
| 2228 | 2237 | try { | |
| 2229 | 2238 | // append to wrong key | |
| 2230 | 2239 | String str = "{\"myKey\":true, \"myOtherKey\":false}"; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments