aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/plugins.ts4
-rw-r--r--server/middlewares/validators/videos/video-blacklist.ts9
2 files changed, 8 insertions, 5 deletions
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts
index 2cb49ec43..cba261dc0 100644
--- a/server/middlewares/validators/plugins.ts
+++ b/server/middlewares/validators/plugins.ts
@@ -4,7 +4,7 @@ import { 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, toBooleanOrNull, exists } from '../../helpers/custom-validators/misc' 7import { isBooleanValid, isSafePath, toBooleanOrNull, exists, toIntOrNull } 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'
@@ -75,6 +75,7 @@ const pluginStaticDirectoryValidator = [
75const listPluginsValidator = [ 75const listPluginsValidator = [
76 query('pluginType') 76 query('pluginType')
77 .optional() 77 .optional()
78 .customSanitizer(toIntOrNull)
78 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), 79 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
79 query('uninstalled') 80 query('uninstalled')
80 .optional() 81 .optional()
@@ -165,6 +166,7 @@ const listAvailablePluginsValidator = [
165 .exists().withMessage('Should have a valid search'), 166 .exists().withMessage('Should have a valid search'),
166 query('pluginType') 167 query('pluginType')
167 .optional() 168 .optional()
169 .customSanitizer(toIntOrNull)
168 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), 170 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
169 query('currentPeerTubeEngine') 171 query('currentPeerTubeEngine')
170 .optional() 172 .optional()
diff --git a/server/middlewares/validators/videos/video-blacklist.ts b/server/middlewares/validators/videos/video-blacklist.ts
index 4bd6a8333..808fefc25 100644
--- a/server/middlewares/validators/videos/video-blacklist.ts
+++ b/server/middlewares/validators/videos/video-blacklist.ts
@@ -1,10 +1,10 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' 3import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'
4import { logger } from '../../../helpers/logger'
5import { areValidationErrors } from '../utils'
6import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist' 4import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist'
5import { logger } from '../../../helpers/logger'
7import { doesVideoBlacklistExist, doesVideoExist } from '../../../helpers/middlewares' 6import { doesVideoBlacklistExist, doesVideoExist } from '../../../helpers/middlewares'
7import { areValidationErrors } from '../utils'
8 8
9const videosBlacklistRemoveValidator = [ 9const videosBlacklistRemoveValidator = [
10 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), 10 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'),
@@ -67,7 +67,8 @@ const videosBlacklistUpdateValidator = [
67 67
68const videosBlacklistFiltersValidator = [ 68const videosBlacklistFiltersValidator = [
69 query('type') 69 query('type')
70 .optional() 70 .optional()
71 .customSanitizer(toIntOrNull)
71 .custom(isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'), 72 .custom(isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'),
72 query('search') 73 query('search')
73 .optional() 74 .optional()