diff --git a/server/controllers/AuthorController.js b/server/controllers/AuthorController.js index 80471ec47..82ed3e50a 100644 --- a/server/controllers/AuthorController.js +++ b/server/controllers/AuthorController.js @@ -10,7 +10,7 @@ const CacheManager = require('../managers/CacheManager') const CoverManager = require('../managers/CoverManager') const AuthorFinder = require('../finders/AuthorFinder') -const { reqSupportsWebp, isValidASIN, clampPositiveInt } = require('../utils/index') +const { reqSupportsWebp, isValidASIN } = require('../utils/index') const naturalSort = createNewSortInstance({ comparer: new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }).compare @@ -412,8 +412,8 @@ class AuthorController { const options = { format: format || (reqSupportsWebp(req) ? 'webp' : 'jpeg'), - height: clampPositiveInt(height ? parseInt(height) : null, 4096), - width: clampPositiveInt(width ? parseInt(width) : null, 4096) + height: height ? parseInt(height) : null, + width: width ? parseInt(width) : null } return CacheManager.handleAuthorCache(res, authorId, options) } diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 1a6b8ac11..5f7bd9736 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -7,7 +7,7 @@ const SocketAuthority = require('../SocketAuthority') const Database = require('../Database') const zipHelpers = require('../utils/zipHelpers') -const { reqSupportsWebp, clampPositiveInt } = require('../utils/index') +const { reqSupportsWebp } = require('../utils/index') const { ScanResult, AudioMimeType } = require('../utils/constants') const { getAudioMimeTypeFromExtname, encodeUriPath } = require('../utils/fileUtils') const LibraryItemScanner = require('../scanner/LibraryItemScanner') @@ -398,8 +398,8 @@ class LibraryItemController { const options = { format: format || (reqSupportsWebp(req) ? 'webp' : 'jpeg'), - height: clampPositiveInt(height ? parseInt(height) : null, 4096), - width: clampPositiveInt(width ? parseInt(width) : null, 4096) + height: height ? parseInt(height) : null, + width: width ? parseInt(width) : null } return CacheManager.handleCoverCache(res, libraryItemId, options) } diff --git a/server/controllers/PodcastController.js b/server/controllers/PodcastController.js index f099d05ed..c70287600 100644 --- a/server/controllers/PodcastController.js +++ b/server/controllers/PodcastController.js @@ -7,7 +7,7 @@ const Database = require('../Database') const fs = require('../libs/fsExtra') const { getPodcastFeed, findMatchingEpisodes } = require('../utils/podcastUtils') -const { getFileTimestampsWithIno, filePathToPOSIX, isSameOrSubPath } = require('../utils/fileUtils') +const { getFileTimestampsWithIno, filePathToPOSIX } = require('../utils/fileUtils') const { validateUrl } = require('../utils/index') const htmlSanitizer = require('../utils/htmlSanitizer') @@ -58,18 +58,8 @@ class PodcastController { return res.status(404).send('Folder not found') } - if (typeof payload.path !== 'string' || !payload.path.trim()) { - return res.status(400).send('Invalid request body. "path" must be a non-empty string') - } - - const libraryFolderPath = filePathToPOSIX(folder.path) const podcastPath = filePathToPOSIX(payload.path) - if (!isSameOrSubPath(libraryFolderPath, podcastPath)) { - Logger.error(`[PodcastController] Create: Podcast path is outside library folder "${libraryFolderPath}": "${podcastPath}"`) - return res.status(400).send('Podcast path must be inside the selected library folder') - } - // Check if a library item with this podcast folder exists already const existingLibraryItem = (await Database.libraryItemModel.count({ @@ -93,7 +83,7 @@ class PodcastController { const libraryItemFolderStats = await getFileTimestampsWithIno(podcastPath) - let relPath = podcastPath.replace(libraryFolderPath, '') + let relPath = payload.path.replace(folder.fullPath, '') if (relPath.startsWith('/')) relPath = relPath.slice(1) let newLibraryItem = null diff --git a/server/utils/index.js b/server/utils/index.js index 49a7c8e67..c7700a783 100644 --- a/server/utils/index.js +++ b/server/utils/index.js @@ -54,16 +54,6 @@ module.exports.isNullOrNaN = (num) => { return num === null || isNaN(num) } -/** - * @param {number|null|undefined} value - * @param {number} max - * @returns {number|null} - */ -module.exports.clampPositiveInt = (value, max) => { - if (value == null || !Number.isFinite(value) || value <= 0) return null - return Math.min(Math.floor(value), max) -} - const xmlToJSON = (xml) => { return new Promise((resolve, reject) => { parseString(xml, (err, results) => { diff --git a/server/utils/podcastUtils.js b/server/utils/podcastUtils.js index 1cb0c4cb4..2042a8e39 100644 --- a/server/utils/podcastUtils.js +++ b/server/utils/podcastUtils.js @@ -217,10 +217,6 @@ function extractEpisodeData(item) { episode[cleanKey] = extractFirstArrayItemString(item, key) }) - if (episode.subtitle) { - episode.subtitle = htmlSanitizer.sanitize(episode.subtitle.trim()) - } - // Extract psc:chapters if duration is set episode.durationSeconds = episode.duration ? timestampToSeconds(episode.duration) : null