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 {
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." , e );
285+ }
282286 break ;
283287 case '"' :
284288 case '\'' :
@@ -433,6 +437,16 @@ public JSONException syntaxError(String message) {
433437 return new JSONException (message + this .toString ());
434438 }
435439
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+ }
436450
437451 /**
438452 * Make a printable string of this JSONTokener.
You can’t perform that action at this time.
0 commit comments