ui: allow blockquote class

This commit is contained in:
undefined committed 2021-08-31 21:43:57 +08:00
1 parent 4bc8ba9af3
commit fffacdc63c
2 files changed
+81 -81

No files matched your search

@@ -1,92 +1,92 @@
const Xss = require('xss'); const Xss = require('xss');
const xss = new Xss.FilterXSS({ const xss = new Xss.FilterXSS({
whiteList: { whiteList: {
a: ['target', 'href', 'title'], a: ['target', 'href', 'title'],
abbr: ['title'], abbr: ['title'],
address: [], address: [],
area: ['shape', 'coords', 'href', 'alt'], area: ['shape', 'coords', 'href', 'alt'],
article: [], article: [],
aside: [], aside: [],
audio: ['autoplay', 'controls', 'loop', 'preload', 'src'], audio: ['autoplay', 'controls', 'loop', 'preload', 'src'],
b: [], b: [],
bdi: ['dir'], bdi: ['dir'],
bdo: ['dir'], bdo: ['dir'],
big: [], big: [],
blockquote: ['cite'], blockquote: ['cite', 'class'],
br: [], br: [],
caption: [], caption: [],
center: [], center: [],
cite: [], cite: [],
code: ['class'], code: ['class'],
col: ['align', 'valign', 'span', 'width'], col: ['align', 'valign', 'span', 'width'],
colgroup: ['align', 'valign', 'span', 'width'], colgroup: ['align', 'valign', 'span', 'width'],
dd: [], dd: [],
del: ['datetime'], del: ['datetime'],
details: ['open'], details: ['open'],
div: ['class'], div: ['class'],
dl: [], dl: [],
dt: [], dt: [],
em: [], em: [],
font: ['color', 'size', 'face'], font: ['color', 'size', 'face'],
h1: [], h1: [],
h2: ['class'], h2: ['class'],
h3: [], h3: [],
h4: [], h4: [],
h5: [], h5: [],
h6: [], h6: [],
header: [], header: [],
hr: [], hr: [],
i: [], i: [],
img: ['src', 'alt', 'title', 'width', 'height'], img: ['src', 'alt', 'title', 'width', 'height'],
ins: ['datetime'], ins: ['datetime'],
li: [], li: [],
mark: [], mark: [],
ol: [], ol: [],
p: [], p: [],
pre: [], pre: [],
s: [], s: [],
section: [], section: [],
small: [], small: [],
span: ['class'], span: ['class'],
sub: [], sub: [],
summary: [], summary: [],
sup: [], sup: [],
strong: [], strong: [],
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'],
tfoot: ['align', 'valign'], tfoot: ['align', 'valign'],
th: ['width', 'rowspan', 'colspan', 'align', 'valign'], th: ['width', 'rowspan', 'colspan', 'align', 'valign'],
thead: ['align', 'valign'], thead: ['align', 'valign'],
tr: ['rowspan', 'align', 'valign'], tr: ['rowspan', 'align', 'valign'],
tt: [], tt: [],
u: [], u: [],
ul: [], ul: [],
var: [], var: [],
video: ['autoplay', 'controls', 'loop', 'preload', 'src', 'height', 'width'], video: ['autoplay', 'controls', 'loop', 'preload', 'src', 'height', 'width'],
}, },
}); });
function xssProtector(md) { function xssProtector(md) {
function protector(state) { function protector(state) {
for (let i = 0; i < state.tokens.length; i++) { for (let i = 0; i < state.tokens.length; i++) {
const cur = state.tokens[i]; const cur = state.tokens[i];
if (cur.type === 'html_block') { if (cur.type === 'html_block') {
cur.content = xss.process(cur.content); cur.content = xss.process(cur.content);
} }
if (cur.type === 'inline') { if (cur.type === 'inline') {
const inlineTokens = cur.children; const inlineTokens = cur.children;
for (let ii = 0; ii < inlineTokens.length; ii++) { for (let ii = 0; ii < inlineTokens.length; ii++) {
if (inlineTokens[ii].type === 'html_inline') { if (inlineTokens[ii].type === 'html_inline') {
inlineTokens[ii].content = xss.process(inlineTokens[ii].content); inlineTokens[ii].content = xss.process(inlineTokens[ii].content);
} }
}
}
} }
}
} }
}
md.core.ruler.after('linkify', 'xss', protector); md.core.ruler.after('linkify', 'xss', protector);
} }
module.exports = { xss, xssProtector }; module.exports = { xss, xssProtector };
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/ui-default", "name": "@hydrooj/ui-default",
"version": "4.18.14", "version": "4.18.15",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"main": "hydro.js", "main": "hydro.js",