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