Skip to content

Commit

Permalink
JSON now throws an error if security is enabled and a string fails de…
Browse files Browse the repository at this point in the history
…coding due to security.
  • Loading branch information
anutron committed Aug 6, 2009
1 parent 5935851 commit 1a0d5b5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Source/Utilities/JSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ var JSON = new Hash({

decode: function(string, secure){
if ($type(string) != 'string' || !string.length) return null;
if (secure && !(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''))) return null;
if (secure && !(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '')))
throw new Error('JSON could not decode the input; security is enabled and the value is not secure.');
return eval('(' + string + ')');
}

Expand Down

0 comments on commit 1a0d5b5

Please sign in to comment.