mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui: fix xss (#775)
This commit is contained in:
1 parent
36c6faf736
commit
09ac293e22
1 file changed
+5
-5
@@ -1,4 +1,4 @@
|
||||
import { FilterXSS, safeAttrValue } from 'xss';
|
||||
import { escapeAttrValue, FilterXSS, safeAttrValue } from 'xss';
|
||||
|
||||
const stack = [];
|
||||
const voidTags = ['br', 'hr', 'input', 'img', 'link', 'source', 'col', 'area', 'base', 'meta', 'embed', 'param', 'track', 'wbr'];
|
||||
@@ -112,8 +112,8 @@ export const xss = new FilterXSS({
|
||||
allowCommentTag: false,
|
||||
stripIgnoreTagBody: ['script'],
|
||||
safeAttrValue(tag, name, value) {
|
||||
if (name === 'id') return `xss-id-${value}`;
|
||||
if (name === 'class') return value.replace(/badge/g, 'xss-badge');
|
||||
if (name === 'id') return escapeAttrValue(`xss-id-${value}`);
|
||||
if (name === 'class') return escapeAttrValue(value.replace(/badge/g, 'xss-badge'));
|
||||
return safeAttrValue(tag, name, value, this.cssFilter);
|
||||
},
|
||||
});
|
||||
@@ -168,8 +168,8 @@ export const xssInline = new FilterXSS({
|
||||
stripIgnoreTag: true,
|
||||
stripIgnoreTagBody: ['script'],
|
||||
safeAttrValue(tag, name, value) {
|
||||
if (name === 'id') return `xss-id-${value}`;
|
||||
if (name === 'class') return value.replace(/badge/g, 'xss-badge');
|
||||
if (name === 'id') return escapeAttrValue(`xss-id-${value}`);
|
||||
if (name === 'class') return escapeAttrValue(value.replace(/badge/g, 'xss-badge'));
|
||||
return safeAttrValue(tag, name, value, this.cssFilter);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user