File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -278,7 +278,11 @@ public String nextString(char quote) throws JSONException {
278
278
sb .append ('\r' );
279
279
break ;
280
280
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." , e );
285
+ }
282
286
break ;
283
287
case '"' :
284
288
case '\'' :
@@ -433,6 +437,16 @@ public JSONException syntaxError(String message) {
433
437
return new JSONException (message + this .toString ());
434
438
}
435
439
440
+ /**
441
+ * Make a JSONException to signal a syntax error.
442
+ *
443
+ * @param message The error message.
444
+ * @param causedBy The throwable that caused the error.
445
+ * @return A JSONException object, suitable for throwing
446
+ */
447
+ public JSONException syntaxError (String message , Throwable causedBy ) {
448
+ return new JSONException (message + this .toString (), causedBy );
449
+ }
436
450
437
451
/**
438
452
* Make a printable string of this JSONTokener.
You can’t perform that action at this time.
0 commit comments