From b43541a34a8fa897de181f2bb1caf20061be3f45 Mon Sep 17 00:00:00 2001 From: Jurgis Sakalauskas Date: Fri, 3 Nov 2023 19:42:25 +0200 Subject: [PATCH] fix file not found with space --- src/Static/static.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Static/static.service.ts b/src/Static/static.service.ts index 2d625ea..cd7cf32 100644 --- a/src/Static/static.service.ts +++ b/src/Static/static.service.ts @@ -12,6 +12,7 @@ import { configService } from '../config/config.service'; @Injectable() export class StaticService { async provideDirIndex(relPath: string): Promise> { + relPath = decodeURI(relPath); if (relPath.indexOf('..') > -1) { throw new UnauthorizedException( 'You are not authorized to visit ' + relPath, @@ -23,7 +24,7 @@ export class StaticService { const stats: Stats | false = await stat(path).catch(() => false); if (stats === false) { - throw new NotFoundException('Path not found: ' + relPath); + throw new NotFoundException('Path is is not found: ' + relPath); } if (!stats.isDirectory()) {