Merge branch 'deyboy90-master'
* deyboy90-master: Enhancing the json reader, adding corresponding test case for it
This commit is contained in:
commit
86ccf826fc
@ -1561,8 +1561,11 @@ public class JsonReader implements Closeable {
|
||||
case '\'':
|
||||
case '"':
|
||||
case '\\':
|
||||
case '/':
|
||||
return escaped;
|
||||
default:
|
||||
return escaped;
|
||||
// throw error when none of the above cases are matched
|
||||
throw syntaxError("Invalid escape sequence");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,6 +174,21 @@ public final class JsonReaderTest extends TestCase {
|
||||
assertEquals(JsonToken.END_DOCUMENT, reader.peek());
|
||||
}
|
||||
|
||||
public void testInvalidJsonInput() throws IOException {
|
||||
String json = "{\n"
|
||||
+ " \"h\\ello\": true,\n"
|
||||
+ " \"foo\": [\"world\"]\n"
|
||||
+ "}";
|
||||
|
||||
JsonReader reader = new JsonReader(reader(json));
|
||||
reader.beginObject();
|
||||
try {
|
||||
reader.nextName();
|
||||
fail();
|
||||
} catch (IOException expected) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testNulls() {
|
||||
try {
|
||||
new JsonReader(null);
|
||||
|
Loading…
Reference in New Issue
Block a user