2019-12-12 04:35:54 +00:00
|
|
|
const xss = require('xss')
|
2018-09-16 04:35:03 +00:00
|
|
|
|
2019-12-12 04:35:54 +00:00
|
|
|
module.exports = {
|
|
|
|
async init(input, config) {
|
|
|
|
if (config.safeHTML) {
|
|
|
|
input = xss(input, {
|
|
|
|
whiteList: {
|
|
|
|
...xss.whiteList,
|
2019-12-19 04:45:19 +00:00
|
|
|
a: ['class', 'id', 'href', 'style', 'target', 'title'],
|
|
|
|
blockquote: ['class', 'id', 'style'],
|
|
|
|
code: ['class', 'style'],
|
2020-02-10 03:54:14 +00:00
|
|
|
details: ['class', 'style'],
|
2020-05-02 19:13:58 +00:00
|
|
|
defs: ['stroke', 'fill', 'stroke-width', 'transform', 'id'],
|
2019-12-19 04:45:19 +00:00
|
|
|
div: ['class', 'id', 'style'],
|
|
|
|
em: ['class', 'style'],
|
2020-05-02 19:13:58 +00:00
|
|
|
figcaption: ['class', 'style', 'id'],
|
|
|
|
figure: ['class', 'style', 'id'],
|
2020-04-30 02:30:56 +00:00
|
|
|
g: ['transform', 'stroke', 'stroke-width', 'fill'],
|
2019-12-19 04:45:19 +00:00
|
|
|
h1: ['class', 'id', 'style'],
|
|
|
|
h2: ['class', 'id', 'style'],
|
|
|
|
h3: ['class', 'id', 'style'],
|
|
|
|
h4: ['class', 'id', 'style'],
|
|
|
|
h5: ['class', 'id', 'style'],
|
|
|
|
h6: ['class', 'id', 'style'],
|
2020-05-02 19:13:58 +00:00
|
|
|
i: ['class', 'id', 'style'],
|
|
|
|
img: ['alt', 'class', 'draggable', 'height', 'id', 'src', 'style', 'width'],
|
2020-03-21 16:49:25 +00:00
|
|
|
input: ['class', 'disabled', 'type', 'checked', 'id'],
|
2020-02-08 21:11:35 +00:00
|
|
|
kbd: ['class'],
|
2020-03-21 16:49:25 +00:00
|
|
|
label: ['class', 'id', 'for'],
|
2020-05-02 19:13:58 +00:00
|
|
|
li: ['class', 'id', 'style'],
|
2020-01-11 00:48:16 +00:00
|
|
|
mark: ['class', 'style'],
|
2020-05-02 19:13:58 +00:00
|
|
|
ol: ['class', 'id', 'style', 'start'],
|
|
|
|
p: ['class', 'id', 'style'],
|
2020-04-30 02:30:56 +00:00
|
|
|
path: ['d', 'style', 'id'],
|
2020-05-02 19:13:58 +00:00
|
|
|
pre: ['class', 'id', 'style'],
|
2020-02-10 03:54:14 +00:00
|
|
|
section: ['class', 'style'],
|
2020-03-06 19:31:05 +00:00
|
|
|
span: ['class', 'style', 'aria-hidden'],
|
2019-12-19 04:45:19 +00:00
|
|
|
strong: ['class', 'style'],
|
2020-05-02 19:13:58 +00:00
|
|
|
summary: ['class', 'id', 'style'],
|
2020-03-06 19:31:05 +00:00
|
|
|
svg: ['width', 'height', 'viewbox', 'preserveaspectratio', 'style'],
|
2019-12-19 04:45:19 +00:00
|
|
|
table: ['border', 'class', 'id', 'style', 'width'],
|
2020-04-27 01:04:08 +00:00
|
|
|
tabset: [],
|
2019-12-19 04:45:19 +00:00
|
|
|
tbody: ['class', 'style'],
|
2020-05-02 19:13:58 +00:00
|
|
|
td: ['align', 'class', 'colspan', 'rowspan', 'style', 'valign', 'id'],
|
2020-04-27 01:04:08 +00:00
|
|
|
template: ['v-slot:tabs', 'v-slot:content'],
|
2020-05-02 19:13:58 +00:00
|
|
|
th: ['align', 'class', 'colspan', 'rowspan', 'style', 'valign', 'id'],
|
2019-12-19 04:45:19 +00:00
|
|
|
thead: ['class', 'style'],
|
2020-05-02 19:13:58 +00:00
|
|
|
tr: ['class', 'rowspan', 'style', 'align', 'valign', 'id'],
|
|
|
|
ul: ['class', 'id', 'style'],
|
2020-04-30 02:30:56 +00:00
|
|
|
use: ['href', 'transform']
|
2019-12-19 04:45:19 +00:00
|
|
|
},
|
|
|
|
css: false
|
2019-12-12 04:35:54 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
return input
|
2018-09-16 04:35:03 +00:00
|
|
|
}
|
|
|
|
}
|