CSP: font-src
HTTP Content-Security-Policy
(CSP 内容安全策略) 中 font
-src
指令定义了 @font-face
加载字体的有效源规则。
CSP 版本 | 1 |
---|---|
指令类型 | Fetch directive |
default-src 替代 |
是。如果 font -src 没有指定,则使用 default-src 指令。 |
语法
font-src
策略可以包含一个或多个源:
Content-Security-Policy: font-src <source>; Content-Security-Policy: font-src <source> <source>;
源代码
<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).
示例
反例
给出这个 CSP 头:
Content-Security-Policy: font-src https://example.com/
以下的字体源将被阻止,不会加载到浏览器中:
<style>
@font-face {
font-family: "MyFont";
src: url("https://not-example.com/font");
}
body {
font-family: "MyFont";
}
</style>
规范
Specification | Status | Comment |
---|---|---|
Content Security Policy Level 3 font-src |
Working Draft | 无变化 |
Content Security Policy Level 2 font-src |
Recommendation | 首次定义 |
浏览器兼容性
No compatibility data found for http.headers.csp.font-src
.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.