π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Extract temporary extension validation helper
Neeraj Gupta25f87d22bd4d
diff --git a/desktop/src/main/utils/temp.ts b/desktop/src/main/utils/temp.tsindex f98c0a22ad..229d8a958e 100644--- a/desktop/src/main/utils/temp.ts+++ b/desktop/src/main/utils/temp.ts@@ -20,8 +20,10 @@ const randomPrefix = () => {return Array(10).fill("").map(randomChar).join("");};+const isValidExtension = (extension: string) => /^[a-z0-9]+$/i.test(extension);+export const makeTempFilePath = async (extension?: string) => {- if (extension && !/^[a-z0-9]+$/i.test(extension))+ if (extension && !isValidExtension(extension))throw new Error("Invalid temporary file extension");const tempDir = await enteTempDirPath();const suffix = extension ? "." + extension : "";@@ -71,7 +73,7 @@ export const makeFileForStreamOrPathOrZipItem = async (Array.isArray(item) && detectedExtension === "tif"? path.extname(item[1]).slice(1): "";- const extension = /^[a-z0-9]+$/i.test(fileNameExtension)+ const extension = isValidExtension(fileNameExtension)? fileNameExtension: detectedExtension;filePath = await makeTempFilePath(extension);