aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/plugins.ts13
-rw-r--r--server/middlewares/validators/themes.ts4
2 files changed, 11 insertions, 6 deletions
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts
index 78c030333..64bef2648 100644
--- a/server/middlewares/validators/plugins.ts
+++ b/server/middlewares/validators/plugins.ts
@@ -4,7 +4,12 @@ import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { PluginType } from '../../../shared/models/plugins/plugin.type' 4import { PluginType } from '../../../shared/models/plugins/plugin.type'
5import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model' 5import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model'
6import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' 6import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
7import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' 7import {
8 isNpmPluginNameValid,
9 isPluginNameValid,
10 isPluginStableOrUnstableVersionValid,
11 isPluginTypeValid
12} from '../../helpers/custom-validators/plugins'
8import { CONFIG } from '../../initializers/config' 13import { CONFIG } from '../../initializers/config'
9import { PluginManager } from '../../lib/plugins/plugin-manager' 14import { PluginManager } from '../../lib/plugins/plugin-manager'
10import { PluginModel } from '../../models/server/plugin' 15import { PluginModel } from '../../models/server/plugin'
@@ -19,7 +24,7 @@ const getPluginValidator = (pluginType: PluginType, withVersion = true) => {
19 if (withVersion) { 24 if (withVersion) {
20 validators.push( 25 validators.push(
21 param('pluginVersion') 26 param('pluginVersion')
22 .custom(isPluginVersionValid) 27 .custom(isPluginStableOrUnstableVersionValid)
23 ) 28 )
24 } 29 }
25 30
@@ -113,7 +118,7 @@ const installOrUpdatePluginValidator = [
113 .custom(isNpmPluginNameValid), 118 .custom(isNpmPluginNameValid),
114 body('pluginVersion') 119 body('pluginVersion')
115 .optional() 120 .optional()
116 .custom(isPluginVersionValid), 121 .custom(isPluginStableOrUnstableVersionValid),
117 body('path') 122 body('path')
118 .optional() 123 .optional()
119 .custom(isSafePath), 124 .custom(isSafePath),
@@ -185,7 +190,7 @@ const listAvailablePluginsValidator = [
185 .custom(isPluginTypeValid), 190 .custom(isPluginTypeValid),
186 query('currentPeerTubeEngine') 191 query('currentPeerTubeEngine')
187 .optional() 192 .optional()
188 .custom(isPluginVersionValid), 193 .custom(isPluginStableOrUnstableVersionValid),
189 194
190 (req: express.Request, res: express.Response, next: express.NextFunction) => { 195 (req: express.Request, res: express.Response, next: express.NextFunction) => {
191 if (areValidationErrors(req, res)) return 196 if (areValidationErrors(req, res)) return
diff --git a/server/middlewares/validators/themes.ts b/server/middlewares/validators/themes.ts
index c130801a0..080b3e096 100644
--- a/server/middlewares/validators/themes.ts
+++ b/server/middlewares/validators/themes.ts
@@ -2,7 +2,7 @@ import express from 'express'
2import { param } from 'express-validator' 2import { param } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { isSafePath } from '../../helpers/custom-validators/misc' 4import { isSafePath } from '../../helpers/custom-validators/misc'
5import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' 5import { isPluginNameValid, isPluginStableOrUnstableVersionValid } from '../../helpers/custom-validators/plugins'
6import { PluginManager } from '../../lib/plugins/plugin-manager' 6import { PluginManager } from '../../lib/plugins/plugin-manager'
7import { areValidationErrors } from './shared' 7import { areValidationErrors } from './shared'
8 8
@@ -10,7 +10,7 @@ const serveThemeCSSValidator = [
10 param('themeName') 10 param('themeName')
11 .custom(isPluginNameValid), 11 .custom(isPluginNameValid),
12 param('themeVersion') 12 param('themeVersion')
13 .custom(isPluginVersionValid), 13 .custom(isPluginStableOrUnstableVersionValid),
14 param('staticEndpoint') 14 param('staticEndpoint')
15 .custom(isSafePath), 15 .custom(isSafePath),
16 16