CSP: script-src-elem
HTTP协议中 Content-Security-Policy
(CSP) script-src-elem
指示符明指定了合法的js要素来源 <script>
,但是不包括类似onclick这样的事件处理器中包含的内联脚本。
CSP 版本 | 3 |
---|---|
Directive type | Fetch directive |
default-src fallback |
Yes. If this directive is absent, the user agent will look for the script-src (en-US) directive, and if both of them are absent, fallback to default-src directive. |
语法
script-src-elem
可以允许多个来源:
Content-Security-Policy: script-src-elem <source>; Content-Security-Policy: script-src-elem <source> <source>;
script-src-elem
可以跟 script-src (en-US)一起用:
Content-Security-Policy: script-src <source>; Content-Security-Policy: script-src-elem <source>;
Sources
<source>
can be any one of the values listed in CSP Source Values.
Note that this same set of values can be used in all fetch directives (and a number of other directives).
范例
回退到 script-src
如果没有 script-src-elem
存在, 客户端会回退到 script-src (en-US) 指示符, 如果那个也还是没有那就回退到 default-src
。
细则
Specification | Status | Comment |
---|---|---|
Content Security Policy Level 3 script-src-elem |
Working Draft | Initial definition. |
浏览器兼容问题
BCD tables only load in the browser