From 3bc8a96afdeb337e6d6972e0c989b11bcdbbe70e Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sat, 7 Aug 2021 15:44:56 +0200 Subject: :bug: fix path --- src/util/FileStorage.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/util/FileStorage.ts') diff --git a/src/util/FileStorage.ts b/src/util/FileStorage.ts index 8001c608..119e990f 100644 --- a/src/util/FileStorage.ts +++ b/src/util/FileStorage.ts @@ -4,8 +4,9 @@ import { join, relative } from "path"; import "missing-native-js-functions"; function getPath(path: string) { + if (path.indexOf("\0") !== -1 || !/^[a-z0-9]+$/.test(path)) throw new Error("invalid path"); // STORAGE_LOCATION has a default value in start.ts - return join(process.env.STORAGE_LOCATION || "../", relative("/", path)); + return join(process.env.STORAGE_LOCATION || "../", path); } export class FileStorage implements Storage { @@ -22,7 +23,6 @@ export class FileStorage implements Storage { } async delete(path: string) { - path = join(process.env.STORAGE_LOCATION || "", path); - fs.unlinkSync(path); + fs.unlinkSync(getPath(path)); } } -- cgit 1.5.1