Appearance
vue/no-v-html
禁止使用 v-html 来防止 XSS 攻击
- ⚙️ 此规则包含在
"plugin:vue/recommended"
、*.configs["flat/recommended"]
、"plugin:vue/vue2-recommended"
和*.configs["flat/vue2-recommended"]
中。
📖 规则详情
此规则报告 v-html
指令的所有使用情况,以降低将潜在的不安全/未转义的 html 注入浏览器导致跨站点脚本 (XSS) 攻击的风险。
¥This rule reports all uses of v-html
directive in order to reduce the risk of injecting potentially unsafe / unescaped html into the browser leading to Cross-Site Scripting (XSS) attacks.
🔧选项
¥🔧 Options
json
{
"vue/no-v-html": ["error", {
"ignorePattern": "^html"
}]
}
ignorePattern
...当v-html
指令引用与此模式匹配的变量时禁用报告。默认情况下,所有v-html
的使用都是被禁止的。¥
ignorePattern
... disables reporting when thev-html
directive references a variable matching this pattern. By default, allv-html
uses are forbidden.
{ "ignorePattern": "^html" }
🔇何时不使用
¥🔇 When Not To Use It
如果你确定传递给 v-html
的内容是经过清理的 HTML,则可以禁用此规则。
¥If you are certain the content passed to v-html
is sanitized HTML you can disable this rule.
👫相关规则
¥👫 Related Rules
🚀版本
¥🚀 Version
此规则在 eslint-plugin-vue v4.7.0 中引入
¥This rule was introduced in eslint-plugin-vue v4.7.0
🔍代码实现
¥🔍 Implementation