aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/misc.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-05 13:54:32 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commit345da516fae80f24c90c2196e96393b489af2243 (patch)
tree64d72d25a531626c1d4a6337460dae4e32386f2a /server/helpers/custom-validators/misc.ts
parent297067399db2bf7505561d67667ca0d559a8e42b (diff)
downloadPeerTube-345da516fae80f24c90c2196e96393b489af2243.tar.gz
PeerTube-345da516fae80f24c90c2196e96393b489af2243.tar.zst
PeerTube-345da516fae80f24c90c2196e96393b489af2243.zip
WIP plugins: add ability to register plugins
Diffstat (limited to 'server/helpers/custom-validators/misc.ts')
-rw-r--r--server/helpers/custom-validators/misc.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts
index 3a3deab0c..f72513c1c 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -1,10 +1,18 @@
1import 'multer' 1import 'multer'
2import * as validator from 'validator' 2import * as validator from 'validator'
3import { sep } from 'path'
3 4
4function exists (value: any) { 5function exists (value: any) {
5 return value !== undefined && value !== null 6 return value !== undefined && value !== null
6} 7}
7 8
9function isSafePath (p: string) {
10 return exists(p) &&
11 (p + '').split(sep).every(part => {
12 return [ '', '.', '..' ].includes(part) === false
13 })
14}
15
8function isArray (value: any) { 16function isArray (value: any) {
9 return Array.isArray(value) 17 return Array.isArray(value)
10} 18}
@@ -97,6 +105,7 @@ export {
97 isNotEmptyIntArray, 105 isNotEmptyIntArray,
98 isArray, 106 isArray,
99 isIdValid, 107 isIdValid,
108 isSafePath,
100 isUUIDValid, 109 isUUIDValid,
101 isIdOrUUIDValid, 110 isIdOrUUIDValid,
102 isDateValid, 111 isDateValid,