mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-02 09:14:40 +02:00
Sanitize media item & episode description on update
This commit is contained in:
parent
4968864498
commit
9052ceedd3
3 changed files with 30 additions and 1 deletions
|
@ -2,6 +2,7 @@ const { DataTypes, Model } = require('sequelize')
|
|||
const { getTitlePrefixAtEnd, getTitleIgnorePrefix } = require('../utils')
|
||||
const Logger = require('../Logger')
|
||||
const libraryItemsPodcastFilters = require('../utils/queries/libraryItemsPodcastFilters')
|
||||
const htmlSanitizer = require('../utils/htmlSanitizer')
|
||||
|
||||
/**
|
||||
* @typedef PodcastExpandedProperties
|
||||
|
@ -215,6 +216,15 @@ class Podcast extends Model {
|
|||
newKey = 'itunesPageURL'
|
||||
}
|
||||
if ((typeof payload.metadata[key] === 'string' || payload.metadata[key] === null) && payload.metadata[key] !== this[newKey]) {
|
||||
// Sanitize description HTML
|
||||
if (key === 'description' && payload.metadata[key]) {
|
||||
const sanitizedDescription = htmlSanitizer.sanitize(payload.metadata[key])
|
||||
if (sanitizedDescription !== payload.metadata[key]) {
|
||||
Logger.debug(`[Podcast] "${this.title}" Sanitized description from "${payload.metadata[key]}" to "${sanitizedDescription}"`)
|
||||
payload.metadata[key] = sanitizedDescription
|
||||
}
|
||||
}
|
||||
|
||||
this[newKey] = payload.metadata[key] || null
|
||||
|
||||
if (key === 'title') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue