内容安全策略允许采用内联样式,而不会出现不安全的内联 [英] Content Security Policy allow inline style without unsafe-inline

查看:55
本文介绍了内容安全策略允许采用内联样式,而不会出现不安全的内联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用不带style-src'unsafe-inline'的内容安全策略,如何允许这样的样式?

Using content security policy without style-src 'unsafe-inline' how do you allow styles like this?

<span style="font-size: 16px;">Hello</span>

我尝试向他们添加一个随机数并将该随机数添加到CSP头中,但这似乎不起作用

I've tried adding a nonce to them and adding that nonce to the CSP header but that doesn't seem to work

<span style="font-size: 16px;" nonce="0611873de7e2db5985c289fdfa946caee2ae1860">Hello</span>

"style-src 'nonce-0611873de7e2db5985c289fdfa946caee2ae1860' 'self'"

是否有任何方法可以执行而无需添加'unsafe-inline'指令?

Is there any way to do this without adding the 'unsafe-inline' directive??

推荐答案

https://bugzilla.mozilla.org/show_bug.cgi?id=855326#c35 不支持样式属性的随机数

According to https://bugzilla.mozilla.org/show_bug.cgi?id=855326#c35 nonces for style attributes isn't supported

这篇关于内容安全策略允许采用内联样式,而不会出现不安全的内联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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