From 75646a0676f752490366ae5dd9148523627c9e9b Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Mon, 21 Nov 2022 22:54:35 +0100 Subject: [PATCH] fixing photo name generating #558 --- .../model/fileprocessing/PhotoProcessing.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/backend/model/fileprocessing/PhotoProcessing.ts b/src/backend/model/fileprocessing/PhotoProcessing.ts index 4fd6678a..75fe80cd 100644 --- a/src/backend/model/fileprocessing/PhotoProcessing.ts +++ b/src/backend/model/fileprocessing/PhotoProcessing.ts @@ -164,7 +164,7 @@ export class PhotoProcessing { const sizeStr = convertedPath.substring( convertedPath.lastIndexOf('_') + 1, - convertedPath.length - path.extname(convertedPath).length + convertedPath.lastIndexOf('q') ); const size = parseInt(sizeStr, 10); @@ -177,6 +177,19 @@ export class PhotoProcessing { return false; } + const qualityStr = convertedPath.substring( + convertedPath.lastIndexOf('q') + 1, + convertedPath.length - path.extname(convertedPath).length + ); + + const quality = parseInt(qualityStr, 10); + + if ((quality + '').length !== qualityStr.length || + quality < 0 || + quality > 100) { + return false; + } + try { await fsp.access(origFilePath, fsConstants.R_OK); } catch (e) {