内容安全策略 - data:image/svg+xml 在 img-src 中被忽略
Content Security Policy - data:image/svg+xml is ignored in img-src
我的CSP header 是这样的(实际上,它只是与加载图像相关的部分),应该是有效的。但是 Chrome 抱怨 "The source list for Content Security Policy directive 'img-src' contains an invalid source: 'data:image/svg+xml'. It will be ignored."
img-src data:image/svg+xml 'self' https://stats.g.doubleclick.net/r/collect https://www.facebook.com/tr/ https://www.google-analytics.com/r/collect data:image/svg+xml;
应该是有效的,我在网络上的示例中找到了它,但它不起作用。比如这里建议https://security.stackexchange.com/questions/94993/is-including-the-data-scheme-in-your-content-security-policy-safe/95011#95011
请提供有效且有效的示例,我迷失在这个迷宫中。
您的示例 CSP 无效。根据 MDN Documentation 你应该只使用主机、模式或其他常量值。更正后,您的示例应如下所示:
img-src 'self' https://stats.g.doubleclick.net/ https://www.facebook.com/ https://www.google-analytics.com/ data:;
我的CSP header 是这样的(实际上,它只是与加载图像相关的部分),应该是有效的。但是 Chrome 抱怨 "The source list for Content Security Policy directive 'img-src' contains an invalid source: 'data:image/svg+xml'. It will be ignored."
img-src data:image/svg+xml 'self' https://stats.g.doubleclick.net/r/collect https://www.facebook.com/tr/ https://www.google-analytics.com/r/collect data:image/svg+xml;
应该是有效的,我在网络上的示例中找到了它,但它不起作用。比如这里建议https://security.stackexchange.com/questions/94993/is-including-the-data-scheme-in-your-content-security-policy-safe/95011#95011
请提供有效且有效的示例,我迷失在这个迷宫中。
您的示例 CSP 无效。根据 MDN Documentation 你应该只使用主机、模式或其他常量值。更正后,您的示例应如下所示:
img-src 'self' https://stats.g.doubleclick.net/ https://www.facebook.com/ https://www.google-analytics.com/ data:;