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 68
68
"@types/qrcode-svg" : " ^1.1.5" ,
69
69
"@types/sharp" : " ^0.32.0" ,
70
70
"@types/supertest" : " ^6.0.2" ,
71
+ "@types/uuid" : " ^10.0.0" ,
71
72
"@typescript-eslint/eslint-plugin" : " ^8.6.0" ,
72
73
"@typescript-eslint/parser" : " ^8.6.0" ,
73
74
"cross-env" : " ^7.0.3" ,
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import * as fs from "fs";
12
12
import * as mime from "mime-types" ;
13
13
import { ConfigService } from "src/config/config.service" ;
14
14
import { PrismaService } from "src/prisma/prisma.service" ;
15
+ import { validate as isValidUUID } from "uuid" ;
15
16
import { SHARE_DIRECTORY } from "../constants" ;
16
17
17
18
@Injectable ( )
@@ -28,7 +29,11 @@ export class FileService {
28
29
file : { id ?: string ; name : string } ,
29
30
shareId : string ,
30
31
) {
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
+ }
32
37
33
38
const share = await this . prisma . share . findUnique ( {
34
39
where : { id : shareId } ,
You can’t perform that action at this time.
0 commit comments