mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 11:25:30 -04:00
Merge pull request #759 from eamonnmcmanus/eofnull
JSON parsing should detect embedded `\0` values
This commit is contained in:
commit
60662e2f83
@ -256,6 +256,9 @@ public class JSONObject {
|
||||
if (x.nextClean() == '}') {
|
||||
return;
|
||||
}
|
||||
if (x.end()) {
|
||||
throw x.syntaxError("A JSONObject text must end with '}'");
|
||||
}
|
||||
x.back();
|
||||
break;
|
||||
case '}':
|
||||
|
@ -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}";
|
||||
|
Loading…
x
Reference in New Issue
Block a user