From 400167f4ef436893a2a956cdd4ec6e4a21431a33 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 18 Sep 2022 21:44:13 -0500 Subject: [PATCH] fix(server): sanitization error that crash the server (#721) --- server/apps/immich/src/config/asset-upload.config.ts | 2 +- server/apps/immich/src/config/profile-image-upload.config.ts | 2 +- server/apps/microservices/src/processors/thumbnail.processor.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/apps/immich/src/config/asset-upload.config.ts b/server/apps/immich/src/config/asset-upload.config.ts index 9ba49ec758..55769e8a8e 100644 --- a/server/apps/immich/src/config/asset-upload.config.ts +++ b/server/apps/immich/src/config/asset-upload.config.ts @@ -25,7 +25,7 @@ export const assetUploadOption: MulterOptions = { return; } - const sanitizedDeviceId = sanitize(req.body['deviceId']); + const sanitizedDeviceId = sanitize(String(req.body['deviceId'])); const originalUploadFolder = join(basePath, req.user.id, 'original', sanitizedDeviceId); if (!existsSync(originalUploadFolder)) { diff --git a/server/apps/immich/src/config/profile-image-upload.config.ts b/server/apps/immich/src/config/profile-image-upload.config.ts index c181147864..0fdb7767b6 100644 --- a/server/apps/immich/src/config/profile-image-upload.config.ts +++ b/server/apps/immich/src/config/profile-image-upload.config.ts @@ -38,7 +38,7 @@ export const profileImageUploadOption: MulterOptions = { const userId = req.user.id; const fileName = `${userId}${extname(file.originalname)}`; - cb(null, sanitize(fileName)); + cb(null, sanitize(String(fileName))); }, }), }; diff --git a/server/apps/microservices/src/processors/thumbnail.processor.ts b/server/apps/microservices/src/processors/thumbnail.processor.ts index ec0606f8c1..eb368f1a82 100644 --- a/server/apps/microservices/src/processors/thumbnail.processor.ts +++ b/server/apps/microservices/src/processors/thumbnail.processor.ts @@ -52,7 +52,7 @@ export class ThumbnailGeneratorProcessor { const basePath = APP_UPLOAD_LOCATION; const { asset } = job.data; - const sanitizedDeviceId = sanitize(asset.deviceId); + const sanitizedDeviceId = sanitize(String(asset.deviceId)); const resizePath = join(basePath, asset.userId, 'thumb', sanitizedDeviceId);