包含哈希值时出现内容安全策略错误

时间:2018-11-29 16:00:00

标签: content-security-policy

我有一个问题,尽管我已经包含(如您所见)内联样式=“ height:18px”(属性)的哈希值,但我仍然遇到csp错误(页面在ghostjs中)

Refused to apply inline style because it violates the following Content 
Security Policy directive: "style-src 'self' maxcdn.bootstrapcdn.com 
fonts.googleapis.com https://intercom.help/_assets 
'sha256-HKIQe1rxf7BKTQyeVymEQz4wG30GqXPn7nokufiyhRk='". 
Either the 'unsafe-inline' keyword, a hash
('sha256-HKIQe1rxf7BKTQyeVymEQz4wG30GqXPn7nokufiyhRk='), or a nonce ('nonce-...') is
required to enable inline execution.

1 个答案:

答案 0 :(得分:0)

内容安全策略白名单哈希不适用于嵌入式样式属性,而仅适用于嵌入式样式。也许在CSP 3.0中会添加此功能

适用于

<style>
body { colod: red; }
</style>

但不适用于

<body style="color:red;">
</body>