Merge commit from fork

Add UUID check for cache manager
This commit is contained in:
advplyr authored and GitHub committed 2026-09-21 16:10:29 -05:00
commit 0fd0483021
1 file changed
+11 -2
+11 -2
View File
@@ -4,8 +4,13 @@ const stream = require('stream')
const Logger = require('../Logger') const Logger = require('../Logger')
const { resizeImage } = require('../utils/ffmpegHelpers') const { resizeImage } = require('../utils/ffmpegHelpers')
const { encodeUriPath } = require('../utils/fileUtils') const { encodeUriPath } = require('../utils/fileUtils')
const { isUUID } = require('../utils/index')
const Database = require('../Database') const Database = require('../Database')
function isValidCacheDimension(dimension) {
return Number.isSafeInteger(dimension) && dimension > 0
}
class CacheManager { class CacheManager {
constructor() { constructor() {
this.CachePath = null this.CachePath = null
@@ -40,7 +45,9 @@ class CacheManager {
const width = options.width || 400 const width = options.width || 400
const height = options.height || null const height = options.height || null
if (!['webp', 'jpeg', 'png'].includes(format)) return res.sendStatus(400) if (!['webp', 'jpeg', 'png'].includes(format) || !isUUID(libraryItemId) || !isValidCacheDimension(width) || (height !== null && !isValidCacheDimension(height))) {
return res.sendStatus(400)
}
res.type(`image/${format}`) res.type(`image/${format}`)
const cachePath = Path.join(this.CoverCachePath, `${libraryItemId}_${width}${height ? `x${height}` : ''}`) + '.' + format const cachePath = Path.join(this.CoverCachePath, `${libraryItemId}_${width}${height ? `x${height}` : ''}`) + '.' + format
@@ -150,7 +157,9 @@ class CacheManager {
const width = options.width || 400 const width = options.width || 400
const height = options.height || null const height = options.height || null
if (!['webp', 'jpeg', 'png'].includes(format)) return res.sendStatus(400) if (!['webp', 'jpeg', 'png'].includes(format) || !isUUID(authorId) || !isValidCacheDimension(width) || (height !== null && !isValidCacheDimension(height))) {
return res.sendStatus(400)
}
res.type(`image/${format}`) res.type(`image/${format}`)
var cachePath = Path.join(this.ImageCachePath, `${authorId}_${width}${height ? `x${height}` : ''}`) + '.' + format var cachePath = Path.join(this.ImageCachePath, `${authorId}_${width}${height ? `x${height}` : ''}`) + '.' + format