mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
28 lines
656 B
JavaScript
28 lines
656 B
JavaScript
const sanitizeHtml = require('../libs/sanitizeHtml')
|
|
|
|
function sanitize(html) {
|
|
const sanitizerOptions = {
|
|
allowedTags: [
|
|
'p', 'ol', 'ul', 'li', 'a', 'strong', 'em', 'del'
|
|
],
|
|
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 |