のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

Refused to evaluate script

Refused to evaluate script because it violates the following Content Security Policy directive: "script-src 'self' https://www.google.com".
Eval and related functions are disabled

Code like the following does not work:

alert(eval("foo.bar.baz"));
window.setTimeout("alert('hi')", 10);
window.setInteral("alert('hi')", 10);
new Function("return foo.bar.baz");

Evaluating strings of JavaScript like this is a common XSS attack vector. Instead, you should write code like:

alert(foo && foo.bar && foo.bar.baz);
window.setTimeout(function() { alert('hi'); }, 10);
window.setInterval(function() { alert('hi'); }, 10);
function() { return foo && foo.bar && foo.bar.baz };

Eval and related functions are disabled