diff options
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/plugins.ts | 13 | ||||
-rw-r--r-- | server/middlewares/validators/themes.ts | 4 |
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' | |||
4 | import { PluginType } from '../../../shared/models/plugins/plugin.type' | 4 | import { PluginType } from '../../../shared/models/plugins/plugin.type' |
5 | import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model' | 5 | import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model' |
6 | import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' | 6 | import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' |
7 | import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' | 7 | import { |
8 | isNpmPluginNameValid, | ||
9 | isPluginNameValid, | ||
10 | isPluginStableOrUnstableVersionValid, | ||
11 | isPluginTypeValid | ||
12 | } from '../../helpers/custom-validators/plugins' | ||
8 | import { CONFIG } from '../../initializers/config' | 13 | import { CONFIG } from '../../initializers/config' |
9 | import { PluginManager } from '../../lib/plugins/plugin-manager' | 14 | import { PluginManager } from '../../lib/plugins/plugin-manager' |
10 | import { PluginModel } from '../../models/server/plugin' | 15 | import { 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' | |||
2 | import { param } from 'express-validator' | 2 | import { param } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { isSafePath } from '../../helpers/custom-validators/misc' | 4 | import { isSafePath } from '../../helpers/custom-validators/misc' |
5 | import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' | 5 | import { isPluginNameValid, isPluginStableOrUnstableVersionValid } from '../../helpers/custom-validators/plugins' |
6 | import { PluginManager } from '../../lib/plugins/plugin-manager' | 6 | import { PluginManager } from '../../lib/plugins/plugin-manager' |
7 | import { areValidationErrors } from './shared' | 7 | import { 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 | ||