mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui: fix safeAttrValue
This commit is contained in:
2 files changed
+6
-4
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
import { FilterXSS } from 'xss';
|
import { FilterXSS, safeAttrValue } from 'xss';
|
||||||
|
|
||||||
const stack = [];
|
const stack = [];
|
||||||
const voidTags = ['br', 'hr', 'input', 'img', 'link', 'source', 'col', 'area', 'base', 'meta', 'embed', 'param', 'track', 'wbr'];
|
const voidTags = ['br', 'hr', 'input', 'img', 'link', 'source', 'col', 'area', 'base', 'meta', 'embed', 'param', 'track', 'wbr'];
|
||||||
@@ -111,9 +111,10 @@ export const xss = new FilterXSS({
|
|||||||
},
|
},
|
||||||
allowCommentTag: false,
|
allowCommentTag: false,
|
||||||
stripIgnoreTagBody: ['script'],
|
stripIgnoreTagBody: ['script'],
|
||||||
safeAttrValue(tag, name, value) { // eslint-disable-line consistent-return
|
safeAttrValue(tag, name, value) {
|
||||||
if (name === 'id') return `xss-id-${value}`;
|
if (name === 'id') return `xss-id-${value}`;
|
||||||
if (name === 'class') return value.replace(/badge/g, 'xss-badge');
|
if (name === 'class') return value.replace(/badge/g, 'xss-badge');
|
||||||
|
return safeAttrValue(tag, name, value, this.cssFilter);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -166,9 +167,10 @@ export const xssInline = new FilterXSS({
|
|||||||
allowCommentTag: false,
|
allowCommentTag: false,
|
||||||
stripIgnoreTag: true,
|
stripIgnoreTag: true,
|
||||||
stripIgnoreTagBody: ['script'],
|
stripIgnoreTagBody: ['script'],
|
||||||
safeAttrValue(tag, name, value) { // eslint-disable-line consistent-return
|
safeAttrValue(tag, name, value) {
|
||||||
if (name === 'id') return `xss-id-${value}`;
|
if (name === 'id') return `xss-id-${value}`;
|
||||||
if (name === 'class') return value.replace(/badge/g, 'xss-badge');
|
if (name === 'class') return value.replace(/badge/g, 'xss-badge');
|
||||||
|
return safeAttrValue(tag, name, value, this.cssFilter);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.49.8",
|
"version": "4.49.9",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "index.ts",
|
"main": "index.ts",
|
||||||
|
|||||||
Reference in new issue
Block a user