I use this method to detect CSP with eval
(also used in AngularJS):
function noUnsafeEval() { try { new Function(''); return false; } catch (err) { return true; } }
But I don’t have a server with CSP on hand to test it thoroughly.
Is it reliable? Can the presence of the string new Function('')
in the code cause an error that cannot be detected?
What is err
? What error gets there ( Error
, TypeError
, etc.)? What does the CSP error message say?
I could not find runtime error documentation in CSP.
estus source share