aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-25 16:23:44 +0200
committerChocobozzz <me@florianbigard.com>2019-07-25 16:23:44 +0200
commitc8861d5dc0436ef4342ce517241e3591fa256a13 (patch)
treeca47c09d1f7f1e2aa62c684d576faa938eb47af7
parentb4c19345c19b0891142c69308cd9447f2161188c (diff)
downloadPeerTube-c8861d5dc0436ef4342ce517241e3591fa256a13.tar.gz
PeerTube-c8861d5dc0436ef4342ce517241e3591fa256a13.tar.zst
PeerTube-c8861d5dc0436ef4342ce517241e3591fa256a13.zip
Fix express validator
-rw-r--r--client/src/app/shared/video/infinite-scroller.directive.ts2
-rw-r--r--client/src/app/shared/video/video-miniature.component.html2
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts4
-rw-r--r--server/helpers/custom-validators/accounts.ts1
-rw-r--r--server/helpers/custom-validators/misc.ts18
-rw-r--r--server/helpers/custom-validators/search.ts2
-rw-r--r--server/helpers/custom-validators/servers.ts4
-rw-r--r--server/helpers/custom-validators/users.ts1
-rw-r--r--server/helpers/custom-validators/video-channels.ts2
-rw-r--r--server/helpers/custom-validators/video-comments.ts1
-rw-r--r--server/helpers/custom-validators/video-imports.ts1
-rw-r--r--server/helpers/custom-validators/videos.ts7
-rw-r--r--server/middlewares/oauth.ts1
-rw-r--r--server/middlewares/pagination.ts2
-rw-r--r--server/middlewares/servers.ts1
-rw-r--r--server/middlewares/sort.ts1
-rw-r--r--server/middlewares/user-right.ts1
-rw-r--r--server/middlewares/validators/account.ts2
-rw-r--r--server/middlewares/validators/activitypub/signature.ts2
-rw-r--r--server/middlewares/validators/avatar.ts2
-rw-r--r--server/middlewares/validators/blocklist.ts2
-rw-r--r--server/middlewares/validators/config.ts2
-rw-r--r--server/middlewares/validators/feeds.ts2
-rw-r--r--server/middlewares/validators/follows.ts2
-rw-r--r--server/middlewares/validators/jobs.ts2
-rw-r--r--server/middlewares/validators/logs.ts2
-rw-r--r--server/middlewares/validators/oembed.ts2
-rw-r--r--server/middlewares/validators/pagination.ts2
-rw-r--r--server/middlewares/validators/plugins.ts6
-rw-r--r--server/middlewares/validators/redundancy.ts7
-rw-r--r--server/middlewares/validators/search.ts2
-rw-r--r--server/middlewares/validators/server.ts2
-rw-r--r--server/middlewares/validators/themes.ts2
-rw-r--r--server/middlewares/validators/user-history.ts3
-rw-r--r--server/middlewares/validators/user-notifications.ts7
-rw-r--r--server/middlewares/validators/user-subscriptions.ts3
-rw-r--r--server/middlewares/validators/users.ts7
-rw-r--r--server/middlewares/validators/utils.ts2
-rw-r--r--server/middlewares/validators/videos/video-abuses.ts3
-rw-r--r--server/middlewares/validators/videos/video-blacklist.ts6
-rw-r--r--server/middlewares/validators/videos/video-captions.ts2
-rw-r--r--server/middlewares/validators/videos/video-channels.ts2
-rw-r--r--server/middlewares/validators/videos/video-comments.ts2
-rw-r--r--server/middlewares/validators/videos/video-imports.ts6
-rw-r--r--server/middlewares/validators/videos/video-playlists.ts17
-rw-r--r--server/middlewares/validators/videos/video-rates.ts3
-rw-r--r--server/middlewares/validators/videos/video-shares.ts3
-rw-r--r--server/middlewares/validators/videos/video-watch.ts6
-rw-r--r--server/middlewares/validators/videos/videos.ts26
-rw-r--r--server/middlewares/validators/webfinger.ts2
-rw-r--r--server/tests/api/check-params/video-imports.ts2
51 files changed, 93 insertions, 101 deletions
diff --git a/client/src/app/shared/video/infinite-scroller.directive.ts b/client/src/app/shared/video/infinite-scroller.directive.ts
index 5f8a1dd6e..b1e88882c 100644
--- a/client/src/app/shared/video/infinite-scroller.directive.ts
+++ b/client/src/app/shared/video/infinite-scroller.directive.ts
@@ -39,7 +39,7 @@ export class InfiniteScrollerDirective implements OnInit, OnDestroy {
39 39
40 const scrollObservable = fromEvent(this.container || window, 'scroll') 40 const scrollObservable = fromEvent(this.container || window, 'scroll')
41 .pipe( 41 .pipe(
42 startWith(null), 42 startWith(null as string), // FIXME: typings
43 throttleTime(200, undefined, throttleOptions), 43 throttleTime(200, undefined, throttleOptions),
44 map(() => this.getScrollInfo()), 44 map(() => this.getScrollInfo()),
45 distinctUntilChanged((o1, o2) => o1.current === o2.current), 45 distinctUntilChanged((o1, o2) => o1.current === o2.current),
diff --git a/client/src/app/shared/video/video-miniature.component.html b/client/src/app/shared/video/video-miniature.component.html
index 7af0f1113..51ca1393d 100644
--- a/client/src/app/shared/video/video-miniature.component.html
+++ b/client/src/app/shared/video/video-miniature.component.html
@@ -31,7 +31,7 @@
31 31
32 <div class="video-info-privacy"> 32 <div class="video-info-privacy">
33 <ng-container *ngIf="displayOptions.privacyText">{{ video.privacy.label }}</ng-container> 33 <ng-container *ngIf="displayOptions.privacyText">{{ video.privacy.label }}</ng-container>
34 <ng-container *ngIf="displayOptions.privacyText && displayOptions.state"> - </ng-container> 34 <ng-container *ngIf="displayOptions.privacyText && getStateLabel(video)"> - </ng-container>
35 <ng-container *ngIf="displayOptions.state">{{ getStateLabel(video) }}</ng-container> 35 <ng-container *ngIf="displayOptions.state">{{ getStateLabel(video) }}</ng-container>
36 </div> 36 </div>
37 37
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts
index 027c2b026..0d499d47f 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch.component.ts
@@ -255,10 +255,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
255 ) 255 )
256 256
257 // Video did change 257 // Video did change
258 forkJoin( 258 forkJoin([
259 videoObs, 259 videoObs,
260 this.videoCaptionService.listCaptions(videoId) 260 this.videoCaptionService.listCaptions(videoId)
261 ) 261 ])
262 .pipe( 262 .pipe(
263 // If 401, the video is private or blacklisted so redirect to 404 263 // If 401, the video is private or blacklisted so redirect to 404
264 catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ])) 264 catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 401, 403, 404 ]))
diff --git a/server/helpers/custom-validators/accounts.ts b/server/helpers/custom-validators/accounts.ts
index be196d2a4..f676669ea 100644
--- a/server/helpers/custom-validators/accounts.ts
+++ b/server/helpers/custom-validators/accounts.ts
@@ -1,4 +1,3 @@
1import 'express-validator'
2import { isUserDescriptionValid, isUserUsernameValid } from './users' 1import { isUserDescriptionValid, isUserUsernameValid } from './users'
3import { exists } from './misc' 2import { exists } from './misc'
4 3
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts
index 3ef38fce1..1b7e00431 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -1,6 +1,7 @@
1import 'multer' 1import 'multer'
2import * as validator from 'validator' 2import * as validator from 'validator'
3import { sep } from 'path' 3import { sep } from 'path'
4import toBoolean = require('validator/lib/toBoolean')
4 5
5function exists (value: any) { 6function exists (value: any) {
6 return value !== undefined && value !== null 7 return value !== undefined && value !== null
@@ -46,9 +47,21 @@ function isBooleanValid (value: any) {
46} 47}
47 48
48function toIntOrNull (value: string) { 49function toIntOrNull (value: string) {
49 if (value === 'null') return null 50 const v = toValueOrNull(value)
51
52 if (v === null || v === undefined) return v
53 if (typeof v === 'number') return v
54
55 return validator.toInt(v)
56}
57
58function toBooleanOrNull (value: any) {
59 const v = toValueOrNull(value)
60
61 if (v === null || v === undefined) return v
62 if (typeof v === 'boolean') return v
50 63
51 return validator.toInt(value) 64 return toBoolean(v)
52} 65}
53 66
54function toValueOrNull (value: string) { 67function toValueOrNull (value: string) {
@@ -110,6 +123,7 @@ export {
110 isIdOrUUIDValid, 123 isIdOrUUIDValid,
111 isDateValid, 124 isDateValid,
112 toValueOrNull, 125 toValueOrNull,
126 toBooleanOrNull,
113 isBooleanValid, 127 isBooleanValid,
114 toIntOrNull, 128 toIntOrNull,
115 toArray, 129 toArray,
diff --git a/server/helpers/custom-validators/search.ts b/server/helpers/custom-validators/search.ts
index 15b389a58..ee732b15a 100644
--- a/server/helpers/custom-validators/search.ts
+++ b/server/helpers/custom-validators/search.ts
@@ -1,6 +1,4 @@
1import * as validator from 'validator' 1import * as validator from 'validator'
2import 'express-validator'
3
4import { isArray } from './misc' 2import { isArray } from './misc'
5 3
6function isNumberArray (value: any) { 4function isNumberArray (value: any) {
diff --git a/server/helpers/custom-validators/servers.ts b/server/helpers/custom-validators/servers.ts
index 5c8bf0d2d..7ced36fd3 100644
--- a/server/helpers/custom-validators/servers.ts
+++ b/server/helpers/custom-validators/servers.ts
@@ -1,7 +1,5 @@
1import * as validator from 'validator' 1import * as validator from 'validator'
2import 'express-validator' 2import { exists, isArray } from './misc'
3
4import { isArray, exists } from './misc'
5import { isTestInstance } from '../core-utils' 3import { isTestInstance } from '../core-utils'
6import { CONSTRAINTS_FIELDS } from '../../initializers/constants' 4import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
7 5
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts
index 738d5cbbf..c56ae14ef 100644
--- a/server/helpers/custom-validators/users.ts
+++ b/server/helpers/custom-validators/users.ts
@@ -1,4 +1,3 @@
1import 'express-validator'
2import * as validator from 'validator' 1import * as validator from 'validator'
3import { UserRole } from '../../../shared' 2import { UserRole } from '../../../shared'
4import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants' 3import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants'
diff --git a/server/helpers/custom-validators/video-channels.ts b/server/helpers/custom-validators/video-channels.ts
index f55f0c8ef..6c52dc093 100644
--- a/server/helpers/custom-validators/video-channels.ts
+++ b/server/helpers/custom-validators/video-channels.ts
@@ -1,5 +1,3 @@
1import 'express-validator'
2import 'multer'
3import * as validator from 'validator' 1import * as validator from 'validator'
4import { CONSTRAINTS_FIELDS } from '../../initializers/constants' 2import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
5import { exists } from './misc' 3import { exists } from './misc'
diff --git a/server/helpers/custom-validators/video-comments.ts b/server/helpers/custom-validators/video-comments.ts
index 0707e2af2..8a7cd7105 100644
--- a/server/helpers/custom-validators/video-comments.ts
+++ b/server/helpers/custom-validators/video-comments.ts
@@ -1,4 +1,3 @@
1import 'express-validator'
2import 'multer' 1import 'multer'
3import * as validator from 'validator' 2import * as validator from 'validator'
4import { CONSTRAINTS_FIELDS } from '../../initializers/constants' 3import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
diff --git a/server/helpers/custom-validators/video-imports.ts b/server/helpers/custom-validators/video-imports.ts
index f4235e2fa..8820c4c0a 100644
--- a/server/helpers/custom-validators/video-imports.ts
+++ b/server/helpers/custom-validators/video-imports.ts
@@ -1,4 +1,3 @@
1import 'express-validator'
2import 'multer' 1import 'multer'
3import * as validator from 'validator' 2import * as validator from 'validator'
4import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_IMPORT_STATES } from '../../initializers/constants' 3import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_IMPORT_STATES } from '../../initializers/constants'
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts
index 157e1a8e3..9ab1ef234 100644
--- a/server/helpers/custom-validators/videos.ts
+++ b/server/helpers/custom-validators/videos.ts
@@ -1,9 +1,6 @@
1import { Response } from 'express'
2import 'express-validator'
3import { values } from 'lodash' 1import { values } from 'lodash'
4import 'multer'
5import * as validator from 'validator' 2import * as validator from 'validator'
6import { UserRight, VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared' 3import { VideoFilter, VideoPrivacy, VideoRateType } from '../../../shared'
7import { 4import {
8 CONSTRAINTS_FIELDS, 5 CONSTRAINTS_FIELDS,
9 MIMETYPES, 6 MIMETYPES,
@@ -13,9 +10,7 @@ import {
13 VIDEO_RATE_TYPES, 10 VIDEO_RATE_TYPES,
14 VIDEO_STATES 11 VIDEO_STATES
15} from '../../initializers/constants' 12} from '../../initializers/constants'
16import { VideoModel } from '../../models/video/video'
17import { exists, isArray, isDateValid, isFileValid } from './misc' 13import { exists, isArray, isDateValid, isFileValid } from './misc'
18import { UserModel } from '../../models/account/user'
19import * as magnetUtil from 'magnet-uri' 14import * as magnetUtil from 'magnet-uri'
20 15
21const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS 16const VIDEOS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.VIDEOS
diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts
index 2b4e300e4..77fb305dd 100644
--- a/server/middlewares/oauth.ts
+++ b/server/middlewares/oauth.ts
@@ -1,6 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import * as OAuthServer from 'express-oauth-server' 2import * as OAuthServer from 'express-oauth-server'
3import 'express-validator'
4import { OAUTH_LIFETIME } from '../initializers/constants' 3import { OAUTH_LIFETIME } from '../initializers/constants'
5import { logger } from '../helpers/logger' 4import { logger } from '../helpers/logger'
6import { Socket } from 'socket.io' 5import { Socket } from 'socket.io'
diff --git a/server/middlewares/pagination.ts b/server/middlewares/pagination.ts
index 83304940f..043869303 100644
--- a/server/middlewares/pagination.ts
+++ b/server/middlewares/pagination.ts
@@ -1,6 +1,4 @@
1import 'express-validator'
2import * as express from 'express' 1import * as express from 'express'
3
4import { PAGINATION } from '../initializers/constants' 2import { PAGINATION } from '../initializers/constants'
5 3
6function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) { 4function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) {
diff --git a/server/middlewares/servers.ts b/server/middlewares/servers.ts
index c52f4685b..9c0af443a 100644
--- a/server/middlewares/servers.ts
+++ b/server/middlewares/servers.ts
@@ -1,5 +1,4 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator'
3import { getHostWithPort } from '../helpers/express-utils' 2import { getHostWithPort } from '../helpers/express-utils'
4 3
5function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) { 4function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) {
diff --git a/server/middlewares/sort.ts b/server/middlewares/sort.ts
index 6507aa5b8..8c27e8237 100644
--- a/server/middlewares/sort.ts
+++ b/server/middlewares/sort.ts
@@ -1,5 +1,4 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator'
3import { SortType } from '../models/utils' 2import { SortType } from '../models/utils'
4 3
5function setDefaultSort (req: express.Request, res: express.Response, next: express.NextFunction) { 4function setDefaultSort (req: express.Request, res: express.Response, next: express.NextFunction) {
diff --git a/server/middlewares/user-right.ts b/server/middlewares/user-right.ts
index 498e3d677..4da7b9802 100644
--- a/server/middlewares/user-right.ts
+++ b/server/middlewares/user-right.ts
@@ -1,5 +1,4 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator'
3import { UserRight } from '../../shared' 2import { UserRight } from '../../shared'
4import { logger } from '../helpers/logger' 3import { logger } from '../helpers/logger'
5 4
diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.ts
index 67e4bf8cc..cbdcef2fd 100644
--- a/server/middlewares/validators/account.ts
+++ b/server/middlewares/validators/account.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param } from 'express-validator/check' 2import { param } from 'express-validator'
3import { isAccountNameValid } from '../../helpers/custom-validators/accounts' 3import { isAccountNameValid } from '../../helpers/custom-validators/accounts'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
5import { areValidationErrors } from './utils' 5import { areValidationErrors } from './utils'
diff --git a/server/middlewares/validators/activitypub/signature.ts b/server/middlewares/validators/activitypub/signature.ts
index be14e92ea..02b191480 100644
--- a/server/middlewares/validators/activitypub/signature.ts
+++ b/server/middlewares/validators/activitypub/signature.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body } from 'express-validator/check' 2import { body } from 'express-validator'
3import { 3import {
4 isSignatureCreatorValid, isSignatureTypeValid, 4 isSignatureCreatorValid, isSignatureTypeValid,
5 isSignatureValueValid 5 isSignatureValueValid
diff --git a/server/middlewares/validators/avatar.ts b/server/middlewares/validators/avatar.ts
index bab3ed118..8623d07e8 100644
--- a/server/middlewares/validators/avatar.ts
+++ b/server/middlewares/validators/avatar.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body } from 'express-validator/check' 2import { body } from 'express-validator'
3import { isAvatarFile } from '../../helpers/custom-validators/users' 3import { isAvatarFile } from '../../helpers/custom-validators/users'
4import { areValidationErrors } from './utils' 4import { areValidationErrors } from './utils'
5import { CONSTRAINTS_FIELDS } from '../../initializers/constants' 5import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.ts
index 63d95e9e0..47a0b1a1c 100644
--- a/server/middlewares/validators/blocklist.ts
+++ b/server/middlewares/validators/blocklist.ts
@@ -1,4 +1,4 @@
1import { body, param } from 'express-validator/check' 1import { body, param } from 'express-validator'
2import * as express from 'express' 2import * as express from 'express'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { areValidationErrors } from './utils' 4import { areValidationErrors } from './utils'
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts
index 9c43da165..5059ed0f2 100644
--- a/server/middlewares/validators/config.ts
+++ b/server/middlewares/validators/config.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body } from 'express-validator/check' 2import { body } from 'express-validator'
3import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users' 3import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
5import { CustomConfig } from '../../../shared/models/server/custom-config.model' 5import { CustomConfig } from '../../../shared/models/server/custom-config.model'
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts
index fa130121f..1bef9891b 100644
--- a/server/middlewares/validators/feeds.ts
+++ b/server/middlewares/validators/feeds.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param, query } from 'express-validator/check' 2import { param, query } from 'express-validator'
3import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc' 3import { isIdOrUUIDValid, isIdValid } from '../../helpers/custom-validators/misc'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
5import { areValidationErrors } from './utils' 5import { areValidationErrors } from './utils'
diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts
index 2e5a02307..c3d772297 100644
--- a/server/middlewares/validators/follows.ts
+++ b/server/middlewares/validators/follows.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param } from 'express-validator/check' 2import { body, param } from 'express-validator'
3import { isTestInstance } from '../../helpers/core-utils' 3import { isTestInstance } from '../../helpers/core-utils'
4import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' 4import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers'
5import { logger } from '../../helpers/logger' 5import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/jobs.ts b/server/middlewares/validators/jobs.ts
index 2f8b1738c..41a8d6899 100644
--- a/server/middlewares/validators/jobs.ts
+++ b/server/middlewares/validators/jobs.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param } from 'express-validator/check' 2import { param } from 'express-validator'
3import { isValidJobState } from '../../helpers/custom-validators/jobs' 3import { isValidJobState } from '../../helpers/custom-validators/jobs'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
5import { areValidationErrors } from './utils' 5import { areValidationErrors } from './utils'
diff --git a/server/middlewares/validators/logs.ts b/server/middlewares/validators/logs.ts
index 7380c6edd..07f3f552f 100644
--- a/server/middlewares/validators/logs.ts
+++ b/server/middlewares/validators/logs.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import { logger } from '../../helpers/logger' 2import { logger } from '../../helpers/logger'
3import { areValidationErrors } from './utils' 3import { areValidationErrors } from './utils'
4import { isDateValid } from '../../helpers/custom-validators/misc' 4import { isDateValid } from '../../helpers/custom-validators/misc'
5import { query } from 'express-validator/check' 5import { query } from 'express-validator'
6import { isValidLogLevel } from '../../helpers/custom-validators/logs' 6import { isValidLogLevel } from '../../helpers/custom-validators/logs'
7 7
8const getLogsValidator = [ 8const getLogsValidator = [
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts
index 505319980..24ba5569d 100644
--- a/server/middlewares/validators/oembed.ts
+++ b/server/middlewares/validators/oembed.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { query } from 'express-validator/check' 2import { query } from 'express-validator'
3import { join } from 'path' 3import { join } from 'path'
4import { isTestInstance } from '../../helpers/core-utils' 4import { isTestInstance } from '../../helpers/core-utils'
5import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' 5import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/pagination.ts b/server/middlewares/validators/pagination.ts
index e1ed8cd65..80ae57c0b 100644
--- a/server/middlewares/validators/pagination.ts
+++ b/server/middlewares/validators/pagination.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { query } from 'express-validator/check' 2import { query } from 'express-validator'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { areValidationErrors } from './utils' 4import { areValidationErrors } from './utils'
5 5
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts
index dc3f1454a..910d03c29 100644
--- a/server/middlewares/validators/plugins.ts
+++ b/server/middlewares/validators/plugins.ts
@@ -1,10 +1,10 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param, query } from 'express-validator/check' 2import { body, param, query } from 'express-validator'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { areValidationErrors } from './utils' 4import { areValidationErrors } from './utils'
5import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' 5import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
6import { PluginManager } from '../../lib/plugins/plugin-manager' 6import { PluginManager } from '../../lib/plugins/plugin-manager'
7import { isBooleanValid, isSafePath } from '../../helpers/custom-validators/misc' 7import { isBooleanValid, isSafePath, toBooleanOrNull } from '../../helpers/custom-validators/misc'
8import { PluginModel } from '../../models/server/plugin' 8import { PluginModel } from '../../models/server/plugin'
9import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' 9import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model'
10import { PluginType } from '../../../shared/models/plugins/plugin.type' 10import { PluginType } from '../../../shared/models/plugins/plugin.type'
@@ -39,7 +39,7 @@ const listPluginsValidator = [
39 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), 39 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
40 query('uninstalled') 40 query('uninstalled')
41 .optional() 41 .optional()
42 .toBoolean() 42 .customSanitizer(toBooleanOrNull)
43 .custom(isBooleanValid).withMessage('Should have a valid uninstalled attribute'), 43 .custom(isBooleanValid).withMessage('Should have a valid uninstalled attribute'),
44 44
45 (req: express.Request, res: express.Response, next: express.NextFunction) => { 45 (req: express.Request, res: express.Response, next: express.NextFunction) => {
diff --git a/server/middlewares/validators/redundancy.ts b/server/middlewares/validators/redundancy.ts
index edc53a6b2..1fdac0e4e 100644
--- a/server/middlewares/validators/redundancy.ts
+++ b/server/middlewares/validators/redundancy.ts
@@ -1,7 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator' 2import { body, param } from 'express-validator'
3import { body, param } from 'express-validator/check' 3import { exists, isBooleanValid, isIdOrUUIDValid, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
4import { exists, isBooleanValid, isIdOrUUIDValid, toIntOrNull } from '../../helpers/custom-validators/misc'
5import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
6import { areValidationErrors } from './utils' 5import { areValidationErrors } from './utils'
7import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy' 6import { VideoRedundancyModel } from '../../models/redundancy/video-redundancy'
@@ -68,7 +67,7 @@ const videoPlaylistRedundancyGetValidator = [
68const updateServerRedundancyValidator = [ 67const updateServerRedundancyValidator = [
69 param('host').custom(isHostValid).withMessage('Should have a valid host'), 68 param('host').custom(isHostValid).withMessage('Should have a valid host'),
70 body('redundancyAllowed') 69 body('redundancyAllowed')
71 .toBoolean() 70 .customSanitizer(toBooleanOrNull)
72 .custom(isBooleanValid).withMessage('Should have a valid redundancyAllowed attribute'), 71 .custom(isBooleanValid).withMessage('Should have a valid redundancyAllowed attribute'),
73 72
74 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 73 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
diff --git a/server/middlewares/validators/search.ts b/server/middlewares/validators/search.ts
index 7816d229c..5a3c83f2c 100644
--- a/server/middlewares/validators/search.ts
+++ b/server/middlewares/validators/search.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { areValidationErrors } from './utils' 2import { areValidationErrors } from './utils'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { query } from 'express-validator/check' 4import { query } from 'express-validator'
5import { isDateValid } from '../../helpers/custom-validators/misc' 5import { isDateValid } from '../../helpers/custom-validators/misc'
6 6
7const videosSearchValidator = [ 7const videosSearchValidator = [
diff --git a/server/middlewares/validators/server.ts b/server/middlewares/validators/server.ts
index 6eff8e9ee..f6812647b 100644
--- a/server/middlewares/validators/server.ts
+++ b/server/middlewares/validators/server.ts
@@ -3,7 +3,7 @@ import { logger } from '../../helpers/logger'
3import { areValidationErrors } from './utils' 3import { areValidationErrors } from './utils'
4import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers' 4import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers'
5import { ServerModel } from '../../models/server/server' 5import { ServerModel } from '../../models/server/server'
6import { body } from 'express-validator/check' 6import { body } from 'express-validator'
7import { isUserDisplayNameValid } from '../../helpers/custom-validators/users' 7import { isUserDisplayNameValid } from '../../helpers/custom-validators/users'
8import { Emailer } from '../../lib/emailer' 8import { Emailer } from '../../lib/emailer'
9import { Redis } from '../../lib/redis' 9import { Redis } from '../../lib/redis'
diff --git a/server/middlewares/validators/themes.ts b/server/middlewares/validators/themes.ts
index 642f2df78..24a9673f7 100644
--- a/server/middlewares/validators/themes.ts
+++ b/server/middlewares/validators/themes.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param } from 'express-validator/check' 2import { param } from 'express-validator'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import { areValidationErrors } from './utils' 4import { areValidationErrors } from './utils'
5import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' 5import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
diff --git a/server/middlewares/validators/user-history.ts b/server/middlewares/validators/user-history.ts
index 418313d09..2f1d3cc41 100644
--- a/server/middlewares/validators/user-history.ts
+++ b/server/middlewares/validators/user-history.ts
@@ -1,6 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator' 2import { body } from 'express-validator'
3import { body } from 'express-validator/check'
4import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
5import { areValidationErrors } from './utils' 4import { areValidationErrors } from './utils'
6import { isDateValid } from '../../helpers/custom-validators/misc' 5import { isDateValid } from '../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/user-notifications.ts b/server/middlewares/validators/user-notifications.ts
index 3ded8d8cf..308b32655 100644
--- a/server/middlewares/validators/user-notifications.ts
+++ b/server/middlewares/validators/user-notifications.ts
@@ -1,15 +1,14 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator' 2import { body, query } from 'express-validator'
3import { body, query } from 'express-validator/check'
4import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
5import { areValidationErrors } from './utils' 4import { areValidationErrors } from './utils'
6import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications' 5import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'
7import { isNotEmptyIntArray } from '../../helpers/custom-validators/misc' 6import { isNotEmptyIntArray, toBooleanOrNull } from '../../helpers/custom-validators/misc'
8 7
9const listUserNotificationsValidator = [ 8const listUserNotificationsValidator = [
10 query('unread') 9 query('unread')
11 .optional() 10 .optional()
12 .toBoolean() 11 .customSanitizer(toBooleanOrNull)
13 .isBoolean().withMessage('Should have a valid unread boolean'), 12 .isBoolean().withMessage('Should have a valid unread boolean'),
14 13
15 (req: express.Request, res: express.Response, next: express.NextFunction) => { 14 (req: express.Request, res: express.Response, next: express.NextFunction) => {
diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/middlewares/validators/user-subscriptions.ts
index 2356745d7..9bc8c87e7 100644
--- a/server/middlewares/validators/user-subscriptions.ts
+++ b/server/middlewares/validators/user-subscriptions.ts
@@ -1,6 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator' 2import { body, param, query } from 'express-validator'
3import { body, param, query } from 'express-validator/check'
4import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
5import { areValidationErrors } from './utils' 4import { areValidationErrors } from './utils'
6import { ActorFollowModel } from '../../models/activitypub/actor-follow' 5import { ActorFollowModel } from '../../models/activitypub/actor-follow'
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index 7002de20d..db03dc231 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -1,9 +1,8 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import * as express from 'express' 2import * as express from 'express'
3import 'express-validator' 3import { body, param } from 'express-validator'
4import { body, param } from 'express-validator/check'
5import { omit } from 'lodash' 4import { omit } from 'lodash'
6import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' 5import { isIdOrUUIDValid, toIntOrNull } from '../../helpers/custom-validators/misc'
7import { 6import {
8 isUserAdminFlagsValid, 7 isUserAdminFlagsValid,
9 isUserAutoPlayVideoValid, 8 isUserAutoPlayVideoValid,
@@ -358,7 +357,7 @@ const usersVerifyEmailValidator = [
358 .not().isEmpty().withMessage('Should have a valid verification string'), 357 .not().isEmpty().withMessage('Should have a valid verification string'),
359 body('isPendingEmail') 358 body('isPendingEmail')
360 .optional() 359 .optional()
361 .toBoolean(), 360 .customSanitizer(toIntOrNull),
362 361
363 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 362 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
364 logger.debug('Checking usersVerifyEmail parameters', { parameters: req.params }) 363 logger.debug('Checking usersVerifyEmail parameters', { parameters: req.params })
diff --git a/server/middlewares/validators/utils.ts b/server/middlewares/validators/utils.ts
index 8f77c9fbd..43e5652fa 100644
--- a/server/middlewares/validators/utils.ts
+++ b/server/middlewares/validators/utils.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { query, validationResult } from 'express-validator/check' 2import { query, validationResult } from 'express-validator'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4 4
5function areValidationErrors (req: express.Request, res: express.Response) { 5function areValidationErrors (req: express.Request, res: express.Response) {
diff --git a/server/middlewares/validators/videos/video-abuses.ts b/server/middlewares/validators/videos/video-abuses.ts
index e176e01af..e27d91bb1 100644
--- a/server/middlewares/validators/videos/video-abuses.ts
+++ b/server/middlewares/validators/videos/video-abuses.ts
@@ -1,6 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator' 2import { body, param } from 'express-validator'
3import { body, param } from 'express-validator/check'
4import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc' 3import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
5import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
6import { areValidationErrors } from '../utils' 5import { areValidationErrors } from '../utils'
diff --git a/server/middlewares/validators/videos/video-blacklist.ts b/server/middlewares/validators/videos/video-blacklist.ts
index db59427c7..3e8c5b30c 100644
--- a/server/middlewares/validators/videos/video-blacklist.ts
+++ b/server/middlewares/validators/videos/video-blacklist.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param, query } from 'express-validator/check' 2import { body, param, query } from 'express-validator'
3import { isBooleanValid, isIdOrUUIDValid } from '../../../helpers/custom-validators/misc' 3import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
5import { areValidationErrors } from '../utils' 5import { areValidationErrors } from '../utils'
6import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist' 6import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist'
@@ -24,7 +24,7 @@ const videosBlacklistAddValidator = [
24 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), 24 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
25 body('unfederate') 25 body('unfederate')
26 .optional() 26 .optional()
27 .toBoolean() 27 .customSanitizer(toBooleanOrNull)
28 .custom(isBooleanValid).withMessage('Should have a valid unfederate boolean'), 28 .custom(isBooleanValid).withMessage('Should have a valid unfederate boolean'),
29 body('reason') 29 body('reason')
30 .optional() 30 .optional()
diff --git a/server/middlewares/validators/videos/video-captions.ts b/server/middlewares/validators/videos/video-captions.ts
index f8739e27f..f5610222a 100644
--- a/server/middlewares/validators/videos/video-captions.ts
+++ b/server/middlewares/validators/videos/video-captions.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { areValidationErrors } from '../utils' 2import { areValidationErrors } from '../utils'
3import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc' 3import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
4import { body, param } from 'express-validator/check' 4import { body, param } from 'express-validator'
5import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' 5import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
6import { UserRight } from '../../../../shared' 6import { UserRight } from '../../../../shared'
7import { logger } from '../../../helpers/logger' 7import { logger } from '../../../helpers/logger'
diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts
index c1065b898..3ee5064fc 100644
--- a/server/middlewares/validators/videos/video-channels.ts
+++ b/server/middlewares/validators/videos/video-channels.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param } from 'express-validator/check' 2import { body, param } from 'express-validator'
3import { UserRight } from '../../../../shared' 3import { UserRight } from '../../../../shared'
4import { 4import {
5 isVideoChannelDescriptionValid, 5 isVideoChannelDescriptionValid,
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts
index 1e3e42833..83a0c24b0 100644
--- a/server/middlewares/validators/videos/video-comments.ts
+++ b/server/middlewares/validators/videos/video-comments.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param } from 'express-validator/check' 2import { body, param } from 'express-validator'
3import { UserRight } from '../../../../shared' 3import { UserRight } from '../../../../shared'
4import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc' 4import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
5import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments' 5import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments'
diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/middlewares/validators/videos/video-imports.ts
index 8b0dd8960..318dad100 100644
--- a/server/middlewares/validators/videos/video-imports.ts
+++ b/server/middlewares/validators/videos/video-imports.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body } from 'express-validator/check' 2import { body } from 'express-validator'
3import { isIdValid } from '../../../helpers/custom-validators/misc' 3import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
5import { areValidationErrors } from '../utils' 5import { areValidationErrors } from '../utils'
6import { getCommonVideoEditAttributes } from './videos' 6import { getCommonVideoEditAttributes } from './videos'
@@ -13,7 +13,7 @@ import { doesVideoChannelOfAccountExist } from '../../../helpers/middlewares'
13 13
14const videoImportAddValidator = getCommonVideoEditAttributes().concat([ 14const videoImportAddValidator = getCommonVideoEditAttributes().concat([
15 body('channelId') 15 body('channelId')
16 .toInt() 16 .customSanitizer(toIntOrNull)
17 .custom(isIdValid).withMessage('Should have correct video channel id'), 17 .custom(isIdValid).withMessage('Should have correct video channel id'),
18 body('targetUrl') 18 body('targetUrl')
19 .optional() 19 .optional()
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts
index 638122a2e..2e9c8aa33 100644
--- a/server/middlewares/validators/videos/video-playlists.ts
+++ b/server/middlewares/validators/videos/video-playlists.ts
@@ -1,12 +1,20 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param, query, ValidationChain } from 'express-validator/check' 2import { body, param, query, ValidationChain } from 'express-validator'
3import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../../shared' 3import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../../shared'
4import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
5import { UserModel } from '../../../models/account/user' 5import { UserModel } from '../../../models/account/user'
6import { areValidationErrors } from '../utils' 6import { areValidationErrors } from '../utils'
7import { isVideoImage } from '../../../helpers/custom-validators/videos' 7import { isVideoImage } from '../../../helpers/custom-validators/videos'
8import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' 8import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
9import { isArrayOf, isIdOrUUIDValid, isIdValid, isUUIDValid, toIntArray, toValueOrNull } from '../../../helpers/custom-validators/misc' 9import {
10 isArrayOf,
11 isIdOrUUIDValid,
12 isIdValid,
13 isUUIDValid,
14 toIntArray,
15 toIntOrNull,
16 toValueOrNull
17} from '../../../helpers/custom-validators/misc'
10import { 18import {
11 isVideoPlaylistDescriptionValid, 19 isVideoPlaylistDescriptionValid,
12 isVideoPlaylistNameValid, 20 isVideoPlaylistNameValid,
@@ -374,12 +382,11 @@ function getCommonPlaylistEditAttributes () {
374 .custom(isVideoPlaylistDescriptionValid).withMessage('Should have a valid description'), 382 .custom(isVideoPlaylistDescriptionValid).withMessage('Should have a valid description'),
375 body('privacy') 383 body('privacy')
376 .optional() 384 .optional()
377 .toInt() 385 .customSanitizer(toIntOrNull)
378 .custom(isVideoPlaylistPrivacyValid).withMessage('Should have correct playlist privacy'), 386 .custom(isVideoPlaylistPrivacyValid).withMessage('Should have correct playlist privacy'),
379 body('videoChannelId') 387 body('videoChannelId')
380 .optional() 388 .optional()
381 .customSanitizer(toValueOrNull) 389 .customSanitizer(toIntOrNull)
382 .toInt()
383 ] as (ValidationChain | express.Handler)[] 390 ] as (ValidationChain | express.Handler)[]
384} 391}
385 392
diff --git a/server/middlewares/validators/videos/video-rates.ts b/server/middlewares/validators/videos/video-rates.ts
index 5bb3f4a51..4021cfecc 100644
--- a/server/middlewares/validators/videos/video-rates.ts
+++ b/server/middlewares/validators/videos/video-rates.ts
@@ -1,6 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator' 2import { body, param, query } from 'express-validator'
3import { body, param, query } from 'express-validator/check'
4import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc' 3import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc'
5import { isRatingValid } from '../../../helpers/custom-validators/video-rates' 4import { isRatingValid } from '../../../helpers/custom-validators/video-rates'
6import { isVideoRatingTypeValid } from '../../../helpers/custom-validators/videos' 5import { isVideoRatingTypeValid } from '../../../helpers/custom-validators/videos'
diff --git a/server/middlewares/validators/videos/video-shares.ts b/server/middlewares/validators/videos/video-shares.ts
index 6f4a1f3e0..ace62be5c 100644
--- a/server/middlewares/validators/videos/video-shares.ts
+++ b/server/middlewares/validators/videos/video-shares.ts
@@ -1,6 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator' 2import { param } from 'express-validator'
3import { param } from 'express-validator/check'
4import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc' 3import { isIdOrUUIDValid, isIdValid } from '../../../helpers/custom-validators/misc'
5import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
6import { VideoShareModel } from '../../../models/video/video-share' 5import { VideoShareModel } from '../../../models/video/video-share'
diff --git a/server/middlewares/validators/videos/video-watch.ts b/server/middlewares/validators/videos/video-watch.ts
index a0b530c75..d6ca1d341 100644
--- a/server/middlewares/validators/videos/video-watch.ts
+++ b/server/middlewares/validators/videos/video-watch.ts
@@ -1,6 +1,6 @@
1import { body, param } from 'express-validator/check' 1import { body, param } from 'express-validator'
2import * as express from 'express' 2import * as express from 'express'
3import { isIdOrUUIDValid } from '../../../helpers/custom-validators/misc' 3import { isIdOrUUIDValid, toIntOrNull } from '../../../helpers/custom-validators/misc'
4import { areValidationErrors } from '../utils' 4import { areValidationErrors } from '../utils'
5import { logger } from '../../../helpers/logger' 5import { logger } from '../../../helpers/logger'
6import { doesVideoExist } from '../../../helpers/middlewares' 6import { doesVideoExist } from '../../../helpers/middlewares'
@@ -8,7 +8,7 @@ import { doesVideoExist } from '../../../helpers/middlewares'
8const videoWatchingValidator = [ 8const videoWatchingValidator = [
9 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'), 9 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid id'),
10 body('currentTime') 10 body('currentTime')
11 .toInt() 11 .customSanitizer(toIntOrNull)
12 .isInt().withMessage('Should have correct current time'), 12 .isInt().withMessage('Should have correct current time'),
13 13
14 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 14 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index 8f5e5c95c..27dfe91ca 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -1,6 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import 'express-validator' 2import { body, param, query, ValidationChain } from 'express-validator'
3import { body, param, query, ValidationChain } from 'express-validator/check'
4import { UserRight, VideoChangeOwnershipStatus, VideoPrivacy } from '../../../../shared' 3import { UserRight, VideoChangeOwnershipStatus, VideoPrivacy } from '../../../../shared'
5import { 4import {
6 isBooleanValid, 5 isBooleanValid,
@@ -9,6 +8,7 @@ import {
9 isIdValid, 8 isIdValid,
10 isUUIDValid, 9 isUUIDValid,
11 toArray, 10 toArray,
11 toBooleanOrNull,
12 toIntOrNull, 12 toIntOrNull,
13 toValueOrNull 13 toValueOrNull
14} from '../../../helpers/custom-validators/misc' 14} from '../../../helpers/custom-validators/misc'
@@ -53,7 +53,7 @@ const videosAddValidator = getCommonVideoEditAttributes().concat([
53 ), 53 ),
54 body('name').custom(isVideoNameValid).withMessage('Should have a valid name'), 54 body('name').custom(isVideoNameValid).withMessage('Should have a valid name'),
55 body('channelId') 55 body('channelId')
56 .toInt() 56 .customSanitizer(toIntOrNull)
57 .custom(isIdValid).withMessage('Should have correct video channel id'), 57 .custom(isIdValid).withMessage('Should have correct video channel id'),
58 58
59 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 59 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
@@ -101,7 +101,7 @@ const videosUpdateValidator = getCommonVideoEditAttributes().concat([
101 .custom(isVideoNameValid).withMessage('Should have a valid name'), 101 .custom(isVideoNameValid).withMessage('Should have a valid name'),
102 body('channelId') 102 body('channelId')
103 .optional() 103 .optional()
104 .toInt() 104 .customSanitizer(toIntOrNull)
105 .custom(isIdValid).withMessage('Should have correct video channel id'), 105 .custom(isIdValid).withMessage('Should have correct video channel id'),
106 106
107 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 107 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
@@ -307,15 +307,15 @@ function getCommonVideoEditAttributes () {
307 .custom(isVideoLanguageValid).withMessage('Should have a valid language'), 307 .custom(isVideoLanguageValid).withMessage('Should have a valid language'),
308 body('nsfw') 308 body('nsfw')
309 .optional() 309 .optional()
310 .toBoolean() 310 .customSanitizer(toBooleanOrNull)
311 .custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'), 311 .custom(isBooleanValid).withMessage('Should have a valid NSFW attribute'),
312 body('waitTranscoding') 312 body('waitTranscoding')
313 .optional() 313 .optional()
314 .toBoolean() 314 .customSanitizer(toBooleanOrNull)
315 .custom(isBooleanValid).withMessage('Should have a valid wait transcoding attribute'), 315 .custom(isBooleanValid).withMessage('Should have a valid wait transcoding attribute'),
316 body('privacy') 316 body('privacy')
317 .optional() 317 .optional()
318 .toInt() 318 .customSanitizer(toValueOrNull)
319 .custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'), 319 .custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'),
320 body('description') 320 body('description')
321 .optional() 321 .optional()
@@ -331,16 +331,16 @@ function getCommonVideoEditAttributes () {
331 .custom(isVideoTagsValid).withMessage('Should have correct tags'), 331 .custom(isVideoTagsValid).withMessage('Should have correct tags'),
332 body('commentsEnabled') 332 body('commentsEnabled')
333 .optional() 333 .optional()
334 .toBoolean() 334 .customSanitizer(toBooleanOrNull)
335 .custom(isBooleanValid).withMessage('Should have comments enabled boolean'), 335 .custom(isBooleanValid).withMessage('Should have comments enabled boolean'),
336 body('downloadEnabled') 336 body('downloadEnabled')
337 .optional() 337 .optional()
338 .toBoolean() 338 .customSanitizer(toBooleanOrNull)
339 .custom(isBooleanValid).withMessage('Should have downloading enabled boolean'), 339 .custom(isBooleanValid).withMessage('Should have downloading enabled boolean'),
340 body('originallyPublishedAt') 340 body('originallyPublishedAt')
341 .optional() 341 .optional()
342 .customSanitizer(toValueOrNull) 342 .customSanitizer(toValueOrNull)
343 .custom(isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'), 343 .custom(isVideoOriginallyPublishedAtValid).withMessage('Should have a valid original publication date'),
344 body('scheduleUpdate') 344 body('scheduleUpdate')
345 .optional() 345 .optional()
346 .customSanitizer(toValueOrNull), 346 .customSanitizer(toValueOrNull),
@@ -349,7 +349,7 @@ function getCommonVideoEditAttributes () {
349 .custom(isDateValid).withMessage('Should have a valid schedule update date'), 349 .custom(isDateValid).withMessage('Should have a valid schedule update date'),
350 body('scheduleUpdate.privacy') 350 body('scheduleUpdate.privacy')
351 .optional() 351 .optional()
352 .toInt() 352 .customSanitizer(toValueOrNull)
353 .custom(isScheduleVideoUpdatePrivacyValid).withMessage('Should have correct schedule update privacy') 353 .custom(isScheduleVideoUpdatePrivacyValid).withMessage('Should have correct schedule update privacy')
354 ] as (ValidationChain | express.Handler)[] 354 ] as (ValidationChain | express.Handler)[]
355} 355}
diff --git a/server/middlewares/validators/webfinger.ts b/server/middlewares/validators/webfinger.ts
index 63a1678ec..d7cfe17f0 100644
--- a/server/middlewares/validators/webfinger.ts
+++ b/server/middlewares/validators/webfinger.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { query } from 'express-validator/check' 2import { query } from 'express-validator'
3import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger' 3import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
5import { ActorModel } from '../../models/activitypub/actor' 5import { ActorModel } from '../../models/activitypub/actor'
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index 8ff115e7b..231d5cc85 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -91,7 +91,7 @@ describe('Test video imports API validator', function () {
91 support: 'my super support text', 91 support: 'my super support text',
92 tags: [ 'tag1', 'tag2' ], 92 tags: [ 'tag1', 'tag2' ],
93 privacy: VideoPrivacy.PUBLIC, 93 privacy: VideoPrivacy.PUBLIC,
94 channelId: channelId 94 channelId
95 } 95 }
96 }) 96 })
97 97