ui: fix xss

This commit is contained in:
undefined committed 2024-03-27 05:53:58 +08:00
1 parent 1fba7ebb38
commit 659c0f75be
1 file changed
+2 -6
@@ -111,11 +111,9 @@ export const xss = new FilterXSS({
},
allowCommentTag: false,
stripIgnoreTagBody: ['script'],
safeAttrValue(tag, name, value) {
safeAttrValue(tag, name, value) { // eslint-disable-line consistent-return
if (name === 'id') return `xss-id-${value}`;
if (name === 'class') return value.replace(/badge/g, 'xss-badge');
if (name === 'href') return value.trim().startsWith('javascript:') ? '#' : value;
return value;
},
});
@@ -168,11 +166,9 @@ export const xssInline = new FilterXSS({
allowCommentTag: false,
stripIgnoreTag: true,
stripIgnoreTagBody: ['script'],
safeAttrValue(tag, name, value) {
safeAttrValue(tag, name, value) { // eslint-disable-line consistent-return
if (name === 'id') return `xss-id-${value}`;
if (name === 'class') return value.replace(/badge/g, 'xss-badge');
if (name === 'href') return value.trim().startsWith('javascript:') ? '#' : value;
return value;
},
});