aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/misc.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators/misc.ts')
-rw-r--r--server/helpers/custom-validators/misc.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts
index fa0f469f6..2c4cd1b9f 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -15,8 +15,12 @@ function isSafePath (p: string) {
15 }) 15 })
16} 16}
17 17
18function isSafeFilename (filename: string, extension: string) { 18function isSafeFilename (filename: string, extension?: string) {
19 return typeof filename === 'string' && !!filename.match(new RegExp(`^[a-z0-9-]+\\.${extension}$`)) 19 const regex = extension
20 ? new RegExp(`^[a-z0-9-]+\\.${extension}$`)
21 : new RegExp(`^[a-z0-9-]+\\.[a-z0-9]{1,8}$`)
22
23 return typeof filename === 'string' && !!filename.match(regex)
20} 24}
21 25
22function isSafePeerTubeFilenameWithoutExtension (filename: string) { 26function isSafePeerTubeFilenameWithoutExtension (filename: string) {