相关疑难解决方法(0)

内容安全策略如何运作?

我在开发者控制台中遇到了一堆错误:

拒绝评估字符串

拒绝执行内联脚本,因为它违反了以下内容安全策略指令

拒绝加载脚本

拒绝加载样式表

这是怎么回事?内容安全策略如何运作?我如何使用Content-Security-PolicyHTTP标头?

具体来说,如何......

  1. ......允许多个来源?
  2. ......使用不同的指令?
  3. ...使用多个指令?
  4. ......处理端口?
  5. ...处理不同的协议?
  6. ......允许file://协议?
  7. ...使用内联样式,脚本和标签<style><script>
  8. ......允许eval()

最后:

  1. 究竟是什么'self'意思?

html javascript security http-headers content-security-policy

218
推荐指数
2
解决办法
16万
查看次数

"找不到Content-Security-Policy元标记." 我的phonegap应用程序出错

在我的系统中更新Cordova 5.0后,我创建了新的应用程序.当我在设备上测试我的应用程序时,我在控制台日志中出现错误:

No Content-Security-Policy meta tag found.
Please add one when using the Cordova-plugin-whitelist plugin.: 23.
Run Code Online (Sandbox Code Playgroud)

我在head部分添加了meta

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src: 'self' 'unsafe-inline' 'unsafe-eval'>
Run Code Online (Sandbox Code Playgroud)

但同样,我在使用应用程序内浏览器插件和其他7个网站链接的应用程序中得到了同样的错误.

whitelist phonegap-plugins cordova

94
推荐指数
3
解决办法
10万
查看次数