X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fmisc.ts;h=ebab4c6b244ba1277a0424c089e535fd9faac131;hb=2a4c0d8bbe29178ae90e776bb9453f86e6d23bd9;hp=3dc5504e32545d611c3b9a1d325621cd6613c87a;hpb=b1dbb9fefc870a90b25f5c0153589f45c9e75e3e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts index 3dc5504e3..ebab4c6b2 100644 --- a/server/helpers/custom-validators/misc.ts +++ b/server/helpers/custom-validators/misc.ts @@ -15,6 +15,10 @@ function isSafePath (p: string) { }) } +function isSafePeerTubeFilenameWithoutExtension (filename: string) { + return filename.match(/^[a-z0-9-]+$/) +} + function isArray (value: any): value is any[] { return Array.isArray(value) } @@ -103,7 +107,13 @@ function checkMimetypeRegex (fileMimeType: string, mimeTypeRegex: string) { // --------------------------------------------------------------------------- function toCompleteUUID (value: string) { - if (isShortUUID(value)) return shortToUUID(value) + if (isShortUUID(value)) { + try { + return shortToUUID(value) + } catch { + return null + } + } return value } @@ -166,5 +176,6 @@ export { areUUIDsValid, toIntArray, isFileValid, + isSafePeerTubeFilenameWithoutExtension, checkMimetypeRegex }