首页 > 解决方案 > MS Edge (Chromium) 不显示设置了内容安全策略 (ERR_BLOCKED_BY_CLIENT) 的 PDF 文档

问题描述

我有一个 Web 应用程序,它提供显示 PDF 的链接。Content-Security-Policy 在 apache 配置 (httpd.conf) 中设置

我现在的问题是在 MS Edge(基于铬)中没有打开/显示 PDF。在 Firefox 中,单击链接会打开新选项卡并加载并显示 PDF。在 MS Edge 中,单击链接会打开新选项卡,但显示错误:

example.domain.org is blocked
Requests to the server have been blocked by an extension.
Try disabling your extensions.
ERR_BLOCKED_BY_CLIENT

没有安装扩展,隐身模式也是如此。
在测试了 Content-Security-Policy 之后,似乎基于 chromium 的浏览器确实处理了与 FireFox 非常不同的 CSP“沙盒”。如果没有“沙盒”策略,它就像在 Firefox 中一样工作。

Header set Content-Security-Policy "base-uri 'self' example.domain.org.com; default-src 'self' example.domain.org.com; form-action 'self' example.domain.org.com; frame-src http://example.domain.org.com; font-src 'self' https://fonts.googleapis.com/ https://fonts.gstatic.com/ https://fonts.googleapis.com/css data:; img-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' https://fonts.googleapis.com 'unsafe-inline'; sandbox allow-forms allow-scripts allow-same-origin allow-popups;"

有没有办法添加基本的 CSP 沙箱(使用诸如 allow-forms allow-scripts allow-same-origin allow-popups 之类的说明符)但仍允许在基于 chromium 的浏览器中打开 PDF?
或者仅通过 httpd.conf 中的一些配置删除 PDF 的 CSP 沙箱?

标签: pdfmicrosoft-edgechromiumhttpd.confcontent-security-policy

解决方案


推荐阅读