@@ -7,6 +7,7 @@ import { jwt, type JWTPayloadSpec } from "@elysiajs/jwt";
77import { staticPlugin } from "@elysiajs/static" ;
88import { Database } from "bun:sqlite" ;
99import { Elysia , t } from "elysia" ;
10+ import sanitize from "sanitize-filename" ;
1011import { BaseHtml } from "./components/base" ;
1112import { Header } from "./components/header" ;
1213import {
@@ -886,6 +887,10 @@ const app = new Elysia({
886887 const converterName = body . convert_to . split ( "," ) [ 1 ] ;
887888 const fileNames = JSON . parse ( body . file_names ) as string [ ] ;
888889
890+ for ( let i = 0 ; i < fileNames . length ; i ++ ) {
891+ fileNames [ i ] = sanitize ( fileNames [ i ] || "" ) ;
892+ }
893+
889894 if ( ! Array . isArray ( fileNames ) || fileNames . length === 0 ) {
890895 return redirect ( `${ WEBROOT } /` , 302 ) ;
891896 }
@@ -1411,7 +1416,7 @@ const app = new Elysia({
14111416 // parse from url encoded string
14121417 const userId = decodeURIComponent ( params . userId ) ;
14131418 const jobId = decodeURIComponent ( params . jobId ) ;
1414- const fileName = decodeURIComponent ( params . fileName ) ;
1419+ const fileName = sanitize ( decodeURIComponent ( params . fileName ) ) ;
14151420
14161421 const filePath = `${ outputDir } ${ userId } /${ jobId } /${ fileName } ` ;
14171422 return Bun . file ( filePath ) ;
0 commit comments