html - 哪些 HTML 元素是不可分割的?

标签 html attributes content-security-policy nonce

在内容安全策略的上下文中,可以有从策略中排除的元素,如果它们具有 nonce相应政策中指定的属性。
显然这适用于某些 HTML 元素,例如<script nonce="..."><style nonce="..." .然而,对于某些人来说,它不起作用,例如 <iframe nonce="..." > .
MDN Documentation写的是提示:

Note: The CSP nonce source can only be apply nonceable elements (e.g. as the <img> element has no nonce attribute, there is no way to associate it with this CSP source).


是否有完整的 nonceable 元素列表?
MDN 列出了 nonce脚本和样式标签的属性。另一方面nonce <link> 的属性未列出元素,但无论如何都可以。还有更多这样的元素吗?
附带问题:为什么是 <img><iframe>不是不可取的?

最佳答案

In the MDN Documentation is written the hint:

Note: The CSP nonce source can only be apply nonceable elements (e.g. as the <img>


是的,同时 Firefox v52.9 版本 25/06/2018 支持 <img> 的随机数, <iframe> , <object > , <embed> , <audio><video> .如果您有 WinXP PC,您可以 ensure that .
如上面的测试所示,目前只有 <style><script>是 nonceables,即使 CSP3 不限制对任何 HTML 元素使用 nonce。

关于html - 哪些 HTML 元素是不可分割的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65693187/

相关文章:

javascript - 如何在整个表格行中制作熄灯效果

javascript - 通过循环将 CSS 类应用于每个 <li> 元素

javascript - 创建导航背景 CSS

c - 在c中通过方法/函数传递结构的问题

cordova - Content-Security-Policy 指令 'child-src' 在当前禁用的标志后面实现

security - 内容安全策略报告-uri 未被识别

javascript - 如何计算从php中选择的每个项目的购物车总数?

python - “模块”对象没有属性 'question' 。类名被视为属性吗?

c# - 如何强制开发人员将属性应用于类?

javascript - Web 应用程序无法在 Edge 浏览器 41 上运行