summary refs log tree commit diff
path: root/src/util/FileStorage.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/FileStorage.ts')
-rw-r--r--src/util/FileStorage.ts6
1 files changed, 3 insertions, 3 deletions
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)); } }