Created
June 21, 2013 18:07
-
-
Save guilhermehn/5833114 to your computer and use it in GitHub Desktop.
tuenti_secure JSON parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tuenti_secure(string) { | |
var regexp1 = /^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/, | |
regexp2 = /\\./g, | |
regexp3 = /"[^"\\\n\r]*"/g; | |
if (!string || typeof string !== "string") { | |
return null; | |
} | |
if (regexp1.test(string.replace(regexp2, "@").replace(regexp3, ""))) { | |
return null; | |
} | |
return eval("(" + string + ")"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment