ui: add xss filter to id attribute (#232)

This commit is contained in:
BATTLEHAWK authored and GitHub committed 2021-10-11 20:04:13 +08:00
1 parent c5f20af2f1
commit 88d6ecb816
1 file changed
+12 -8
@@ -24,17 +24,17 @@ const xss = new Xss.FilterXSS({
dd: [], dd: [],
del: ['datetime'], del: ['datetime'],
details: ['open'], details: ['open'],
div: ['class'], div: ['id','class'],
dl: [], dl: [],
dt: [], dt: [],
em: [], em: [],
font: ['color', 'size', 'face'], font: ['color', 'size', 'face'],
h1: [], h1: ['id'],
h2: ['class'], h2: ['id','class'],
h3: [], h3: ['id'],
h4: [], h4: ['id'],
h5: [], h5: ['id'],
h6: [], h6: ['id'],
header: [], header: [],
hr: [], hr: [],
i: [], i: [],
@@ -52,7 +52,7 @@ const xss = new Xss.FilterXSS({
sub: [], sub: [],
summary: [], summary: [],
sup: [], sup: [],
strong: [], strong: ['id'],
table: ['width', 'border', 'align', 'valign'], table: ['width', 'border', 'align', 'valign'],
tbody: ['align', 'valign'], tbody: ['align', 'valign'],
td: ['width', 'rowspan', 'colspan', 'align', 'valign', 'bgcolor'], td: ['width', 'rowspan', 'colspan', 'align', 'valign', 'bgcolor'],
@@ -66,6 +66,10 @@ const xss = new Xss.FilterXSS({
var: [], var: [],
video: ['autoplay', 'controls', 'loop', 'preload', 'src', 'height', 'width'], video: ['autoplay', 'controls', 'loop', 'preload', 'src', 'height', 'width'],
}, },
safeAttrValue(tag, name, value) {
if (name === 'id') return `xss-id-${value}`;
return value;
},
}); });
function xssProtector(md) { function xssProtector(md) {