25 lines
587 B
JavaScript
Raw Normal View History

const { JSDOM } = require('jsdom')
const createDOMPurify = require('dompurify')
2018-09-16 00:35:03 -04:00
2019-12-11 23:35:54 -05:00
module.exports = {
async init(input, config) {
if (config.safeHTML) {
const window = new JSDOM('').window
const DOMPurify = createDOMPurify(window)
const allowedAttrs = ['v-pre', 'v-slot:tabs', 'v-slot:content']
const allowedTags = ['tabset', 'template']
if (config.allowIFrames) {
allowedTags.push('iframe')
}
input = DOMPurify.sanitize(input, {
ADD_ATTR: allowedAttrs,
ADD_TAGS: allowedTags
2019-12-11 23:35:54 -05:00
})
}
return input
2018-09-16 00:35:03 -04:00
}
}