2022-05-28 02:41:40 +02:00
|
|
|
const sanitizeHtml = require('../libs/sanitizeHtml')
|
|
|
|
|
|
|
|
function sanitize(html) {
|
|
|
|
const sanitizerOptions = {
|
|
|
|
allowedTags: [
|
2022-05-28 20:36:58 +02:00
|
|
|
'p', 'ol', 'ul', 'li', 'a', 'strong', 'em', 'del'
|
2022-05-28 02:41:40 +02:00
|
|
|
],
|
|
|
|
disallowedTagsMode: 'discard',
|
|
|
|
allowedAttributes: {
|
|
|
|
a: ['href', 'name', 'target']
|
|
|
|
},
|
|
|
|
allowedSchemes: ['https'],
|
|
|
|
allowProtocolRelative: false
|
|
|
|
}
|
|
|
|
|
|
|
|
return sanitizeHtml(html, sanitizerOptions)
|
|
|
|
}
|
|
|
|
module.exports.sanitize = sanitize
|
|
|
|
|
|
|
|
function stripAllTags(html) {
|
|
|
|
const sanitizerOptions = {
|
|
|
|
allowedTags: [],
|
|
|
|
disallowedTagsMode: 'discard'
|
|
|
|
}
|
|
|
|
|
|
|
|
return sanitizeHtml(html, sanitizerOptions)
|
|
|
|
}
|
|
|
|
module.exports.stripAllTags = stripAllTags
|