Skip to content

Commit

Permalink
Feat #5: add new lines to make JsonReader able to detect unescaped co…
Browse files Browse the repository at this point in the history
…ntrol characters (U+0000 through U+001F) and throw exceptions.
  • Loading branch information
LMC117 committed Feb 24, 2023
1 parent 1ae8d81 commit 49f97e7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gson/src/main/java/com/google/gson/stream/JsonReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ int doPeek() throws IOException {
}

int c = nextNonWhitespace(true);

// if in strict mode, throw an exception when meet unescaped control characters (U+0000 through U+001F)
if (strict && c <= '\u001f') {
throw syntaxError("Unescaped control characters");
}

switch (c) {
case ']':
if (peekStack == JsonScope.EMPTY_ARRAY) {
Expand Down

0 comments on commit 49f97e7

Please sign in to comment.