This repository was archived by the owner on Jun 29, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change 6868 "@types/qrcode-svg" : " ^1.1.5" ,
6969 "@types/sharp" : " ^0.32.0" ,
7070 "@types/supertest" : " ^6.0.2" ,
71+ "@types/uuid" : " ^10.0.0" ,
7172 "@typescript-eslint/eslint-plugin" : " ^8.6.0" ,
7273 "@typescript-eslint/parser" : " ^8.6.0" ,
7374 "cross-env" : " ^7.0.3" ,
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import * as fs from "fs";
1212import * as mime from "mime-types" ;
1313import { ConfigService } from "src/config/config.service" ;
1414import { PrismaService } from "src/prisma/prisma.service" ;
15+ import { validate as isValidUUID } from "uuid" ;
1516import { SHARE_DIRECTORY } from "../constants" ;
1617
1718@Injectable ( )
@@ -28,7 +29,11 @@ export class FileService {
2829 file : { id ?: string ; name : string } ,
2930 shareId : string ,
3031 ) {
31- if ( ! file . id ) file . id = crypto . randomUUID ( ) ;
32+ if ( ! file . id ) {
33+ file . id = crypto . randomUUID ( ) ;
34+ } else if ( ! isValidUUID ( file . id ) ) {
35+ throw new BadRequestException ( "Invalid file ID format" ) ;
36+ }
3237
3338 const share = await this . prisma . share . findUnique ( {
3439 where : { id : shareId } ,
You can’t perform that action at this time.
0 commit comments