I have used eval but disallowing it by applying CSP. But I am looking for an alternative to it.
I found the function jQuery.globaleval()
.
jQuery.readyException = function( error ) {
window.setTimeout( function() {
throw error;
});
};
throws:
Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' http://localhost:6060/WCUSTODY/ http://localhost:6060/application/scripts
So, can we use global eval as an alternative to eval, should also accepted by CSP (Content Security Policy).
jQuery.globalEval()
? You'll note they specifically talk about using a nonce for CSP... – Heretic Monkey