diff options
Diffstat (limited to 'server/helpers/custom-validators/misc.ts')
-rw-r--r-- | server/helpers/custom-validators/misc.ts | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index ebab4c6b2..fa0f469f6 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts | |||
@@ -15,6 +15,10 @@ function isSafePath (p: string) { | |||
15 | }) | 15 | }) |
16 | } | 16 | } |
17 | 17 | ||
18 | function isSafeFilename (filename: string, extension: string) { | ||
19 | return typeof filename === 'string' && !!filename.match(new RegExp(`^[a-z0-9-]+\\.${extension}$`)) | ||
20 | } | ||
21 | |||
18 | function isSafePeerTubeFilenameWithoutExtension (filename: string) { | 22 | function isSafePeerTubeFilenameWithoutExtension (filename: string) { |
19 | return filename.match(/^[a-z0-9-]+$/) | 23 | return filename.match(/^[a-z0-9-]+$/) |
20 | } | 24 | } |
@@ -177,5 +181,6 @@ export { | |||
177 | toIntArray, | 181 | toIntArray, |
178 | isFileValid, | 182 | isFileValid, |
179 | isSafePeerTubeFilenameWithoutExtension, | 183 | isSafePeerTubeFilenameWithoutExtension, |
184 | isSafeFilename, | ||
180 | checkMimetypeRegex | 185 | checkMimetypeRegex |
181 | } | 186 | } |