mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-09 20:14:28 +08:00
Don't skip past \0
when parsing JSON objects.
A better solution might be to use -1 instead 0 to represent EOF everywhere, which of course means changing `char` variables to `int`. The solution here is enough to solve the immediate problem, though. Fixes #758.
This commit is contained in:
@@ -2225,6 +2225,15 @@ public class JSONObjectTest {
|
||||
"Expected a ',' or '}' at 15 [character 16 line 1]",
|
||||
e.getMessage());
|
||||
}
|
||||
try {
|
||||
// \0 after ,
|
||||
String str = "{\"myKey\":true, \0\"myOtherKey\":false}";
|
||||
assertNull("Expected an exception",new JSONObject(str));
|
||||
} catch (JSONException e) {
|
||||
assertEquals("Expecting an exception message",
|
||||
"A JSONObject text must end with '}' at 15 [character 16 line 1]",
|
||||
e.getMessage());
|
||||
}
|
||||
try {
|
||||
// append to wrong key
|
||||
String str = "{\"myKey\":true, \"myOtherKey\":false}";
|
||||
|
Reference in New Issue
Block a user