mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-11-13 12:23:34 +01:00
Merge branch 'master' of https://github.com/advplyr/audiobookshelf
This commit is contained in:
commit
63a883e595
1 file changed
+11
-2
@@ -4,8 +4,13 @@ const stream = require('stream')
|
||||
const Logger = require('../Logger')
|
||||
const { resizeImage } = require('../utils/ffmpegHelpers')
|
||||
const { encodeUriPath } = require('../utils/fileUtils')
|
||||
const { isUUID } = require('../utils/index')
|
||||
const Database = require('../Database')
|
||||
|
||||
function isValidCacheDimension(dimension) {
|
||||
return Number.isSafeInteger(dimension) && dimension > 0
|
||||
}
|
||||
|
||||
class CacheManager {
|
||||
constructor() {
|
||||
this.CachePath = null
|
||||
@@ -40,7 +45,9 @@ class CacheManager {
|
||||
const width = options.width || 400
|
||||
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}`)
|
||||
|
||||
const cachePath = Path.join(this.CoverCachePath, `${libraryItemId}_${width}${height ? `x${height}` : ''}`) + '.' + format
|
||||
@@ -150,7 +157,9 @@ class CacheManager {
|
||||
const width = options.width || 400
|
||||
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}`)
|
||||
|
||||
var cachePath = Path.join(this.ImageCachePath, `${authorId}_${width}${height ? `x${height}` : ''}`) + '.' + format
|
||||
|
||||
Reference in new issue
Block a user