From a02b93ce756d646a59cef57b5e4ff53c2bb30bec Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 6 Aug 2020 16:14:58 +0200 Subject: Fix lint --- server/middlewares/validators/plugins.ts | 4 +++- server/middlewares/validators/videos/video-blacklist.ts | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'server/middlewares') 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' import { areValidationErrors } from './utils' import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' import { PluginManager } from '../../lib/plugins/plugin-manager' -import { isBooleanValid, isSafePath, toBooleanOrNull, exists } from '../../helpers/custom-validators/misc' +import { isBooleanValid, isSafePath, toBooleanOrNull, exists, toIntOrNull } from '../../helpers/custom-validators/misc' import { PluginModel } from '../../models/server/plugin' import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' import { PluginType } from '../../../shared/models/plugins/plugin.type' @@ -75,6 +75,7 @@ const pluginStaticDirectoryValidator = [ const listPluginsValidator = [ query('pluginType') .optional() + .customSanitizer(toIntOrNull) .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), query('uninstalled') .optional() @@ -165,6 +166,7 @@ const listAvailablePluginsValidator = [ .exists().withMessage('Should have a valid search'), query('pluginType') .optional() + .customSanitizer(toIntOrNull) .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), query('currentPeerTubeEngine') .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 @@ import * as express from 'express' import { body, param, query } from 'express-validator' -import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' -import { logger } from '../../../helpers/logger' -import { areValidationErrors } from '../utils' +import { isBooleanValid, isIdOrUUIDValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist' +import { logger } from '../../../helpers/logger' import { doesVideoBlacklistExist, doesVideoExist } from '../../../helpers/middlewares' +import { areValidationErrors } from '../utils' const videosBlacklistRemoveValidator = [ param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid videoId'), @@ -67,7 +67,8 @@ const videosBlacklistUpdateValidator = [ const videosBlacklistFiltersValidator = [ query('type') - .optional() + .optional() + .customSanitizer(toIntOrNull) .custom(isVideoBlacklistTypeValid).withMessage('Should have a valid video blacklist type attribute'), query('search') .optional() -- cgit v1.2.3