mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-04 03:45:35 -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() == '}') {
|
if (x.nextClean() == '}') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (x.end()) {
|
||||||
|
throw x.syntaxError("A JSONObject text must end with '}'");
|
||||||
|
}
|
||||||
x.back();
|
x.back();
|
||||||
break;
|
break;
|
||||||
case '}':
|
case '}':
|
||||||
|
@ -2225,6 +2225,15 @@ public class JSONObjectTest {
|
|||||||
"Expected a ',' or '}' at 15 [character 16 line 1]",
|
"Expected a ',' or '}' at 15 [character 16 line 1]",
|
||||||
e.getMessage());
|
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 {
|
try {
|
||||||
// append to wrong key
|
// append to wrong key
|
||||||
String str = "{\"myKey\":true, \"myOtherKey\":false}";
|
String str = "{\"myKey\":true, \"myOtherKey\":false}";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user