Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dfa651e

Browse files
committed
Make nextString throw a JSONException instead of a NumberFormatException for malformed input.
1 parent 612dafc commit dfa651e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

JSONTokener.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,11 @@ public String nextString(char quote) throws JSONException {
278278
sb.append('\r');
279279
break;
280280
case 'u':
281-
sb.append((char)Integer.parseInt(this.next(4), 16));
281+
try {
282+
sb.append((char)Integer.parseInt(this.next(4), 16));
283+
} catch (NumberFormatException e) {
284+
throw this.syntaxError("Illegal escape.");
285+
}
282286
break;
283287
case '"':
284288
case '\'':

0 commit comments

Comments
 (0)