我正在使用 Chrome 版本 31.0.1650.63 m。
最近,我注意到 Chrome 开发者控制台中抛出了一些错误,但我的网站似乎没有任何问题。经过调查,它们似乎与嵌入的 youtube 链接有关。有问题的标记如下:
<iframe width="560" height="315" src="http://www.youtube.com/embed/hhhrWFxWQRk" frameborder="0" allowfullscreen></iframe>
视频本身无关紧要(我只是捕获了我在 youtubes 首页上看到的第一个视频作为测试),但我已经包含了我在这里使用的链接,以防万一发生了非常具体的事情。
Chrome 中发出的请求的响应 header 如下:
Alternate-Protocol:80:quic
Cache-Control:no-cache
Content-Encoding:gzip
Content-Length:2560
Content-Type:text/html; charset=utf-8
Date:Sun, 12 Jan 2014 20:35:54 GMT
Expires:Tue, 27 Apr 1971 19:44:06 EST
Server:gwiseguy/2.0
X-Content-Type-Options:nosniff
X-Frame-Options:ALLOWALL
X-XSS-Protection:1; mode=block; report=https://www.google.com/appserve/security-bugs/log/youtube
我在 Chrome 开发者控制台中遇到的错误如下:
Invalid 'X-Frame-Options' header encountered when loading 'http://www.youtube.com/embed/hhhrWFxWQRk': 'sil' is not a recognized directive. The header will be ignored.
Error parsing header X-XSS-Protection: sil: expected 0 or 1 at character position 0. The default protections will be applied.
大红字。我注意到的第一件事是错误都引用了值“sil”,我在 HTTP 请求的任何响应 header 中都没有看到它。
视频显示和播放正常,错误表明将使用默认设置 - 所以这看起来不是问题。但是,我很想了解发生了什么,以及为什么会发生这些错误。
我注意到这些错误与 XSS 相关,根据我的研究,我认为 X-XSS-Protection header is for IE8 only ,并且从 YouTube 返回的值无效(report= et al)。 X-Frame-Options header 的值似乎是 invalid根据规范,但 Wikipedia (我知道!)引用 ALLOWALL 选项:
In addition to that, some advertising sites return a non-standard ALLOWALL value with the intention to allow framing their content on any page (equivalent of not setting X-Frame-Options at all).[31]
这是一个有效的担忧吗?这是 Chrome 解析错误,是 youtube 标题的问题,还是我完全没有捕获重点?
我还在 Firefox v26、IE 11.0.6600.16476 和 Opera 12.16 中做了一些测试,这些浏览器都没有产生这个错误。
最佳答案
看起来这是那个特定版本的 Chrome 的问题 - 现在 Chrome 已经更新到 v32,我不再遇到这个问题。但是,我收到了更多与链接到 YouTube 相关的警告和错误。
关于google-chrome - Chrome 开发者控制台在嵌入 youtube 链接时抛出 X-XSS-Protection 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21080715/