diff --git a/src/Server.ts b/src/Server.ts
index 9996f07a..f79437d5 100644
--- a/src/Server.ts
+++ b/src/Server.ts
@@ -20,10 +20,25 @@ export class CDNServer extends Server {
console.log("[Database] connected");
await this.registerRoutes(path.join(__dirname, "routes/"));
+
this.app.use("/icons/", avatarsRoute);
this.log("info", "[Server] Route /icons registered");
+
+ this.app.use("/emojis/", avatarsRoute);
+ this.log("info", "[Server] Route /emojis registered");
+
this.app.use("/banners/", avatarsRoute);
this.log("info", "[Server] Route /banners registered");
+
+ this.app.use("/banners/", avatarsRoute);
+ this.log("info", "[Server] Route /banners registered");
+
+ this.app.use("/discover-splashes/", avatarsRoute);
+ this.log("info", "[Server] Route /discover-splashes registered");
+
+ this.app.use("/team-icons/", avatarsRoute);
+ this.log("info", "[Server] Route /team-icons registered");
+
return super.start();
}
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));
}
}
|