trap illegal encoded urls

Massimo Melina committed Feb 7, 2022 at 18:08 UTC 7f72b32300e8df73504bc40d5f6eee04c45a948a
1 file changed +6 -1
src/middlewares.ts
+6 -1
@@ -78,7 +78,12 @@ export const frontendAndSharedFiles: Koa.Middleware = async (ctx, next) => {
78 }
79
80 export const someSecurity: Koa.Middleware = async (ctx, next) => {
81 - if (decodeURI(ctx.path).includes('..'))
81 + try {
82 + if (decodeURI(ctx.path).includes('..'))
83 + return ctx.status = 418
84 + }
85 + catch {
86 return ctx.status = 418
87 + }
88 return next()
89 }