内容安全策略在第1行上失败(Firefox 57.0) [英] Content Security Policy failing on line 1 (Firefox 57.0)

查看:87
本文介绍了内容安全策略在第1行上失败(Firefox 57.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在仅报告模式下使用以下内容安全策略:

I am using the following Content Security Policy in Report-Only mode:

Content-Security-Policy-Report-Only "default-src 'self'; report-uri /log_violations"

当我转到以下网址时带有包含以下内容的HTML页面的服务器:

When I go to a URL on the server with an HTML page containing the following:

<!DOCTYPE html>
<head>
  <title>
    Test document
  </title>
</head>
<html>
  <body>
    Hello
  </body>
</html>

我在第1行的Firefox 57.0中看到以下错误消息:

I am seeing the following error message in Firefox 57.0 on line 1:

Content Security Policy: The page’s settings observed the loading of a 
resource at self ("default-src http://www3.thestar.com"). A CSP report
is being sent. Source: ;!function(){var t=0,e=function(t,e){ret...

在其他浏览器(如Edge,Chrome)中,我没有看到这些错误。

In other browsers, like Edge, Chrome, I haven't seen these errors.

任何人都在想这是Firefox的怪癖还是我的想法?设置不正确?我对为什么该政策拒绝每一页的第一行感到困惑。

Any thoughts on whether this is a Firefox quirk or something I've set up incorrectly? I'm stumped as to why the policy is rejecting line 1 of every page.

推荐答案

您可能已安装并启用了扩展程序将内容注入页面。尝试在新的Firefox配置文件,没有任何扩展名,以查看是否报告了CSP违规行为。

You probably have an extension installed and enabled that is injecting content into the page. Try opening the page in a new Firefox profile without any extensions to see if you see the CSP violation reported.

Firefox计划在CSP中排除扩展名注入的内容检查启动Firefox 58的情况,这样可以减少扩展程序在页面上执行操作时产生的噪音。

Firefox is planning to exclude content injected by extensions in CSP checks starting Firefox 58 so this should reduce the noise from extensions doing stuff on a page.

来自 Mozilla博客


从Firefox 58开始,网页的CSP不适用于扩展插入的
内容。例如,这允许
扩展名将其自身的资源加载到页面中。

Starting with Firefox 58, the CSP of a web page does not apply to content inserted by an extension. This allows, for example, the extension to load its own resources into a page.

这篇关于内容安全策略在第1行上失败(Firefox 57.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆