From e9f887323a5fdad0175f6c006e4813e23f6477d0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 2 Apr 2025 14:36:11 +0200 Subject: [PATCH] Revert "fix: plugin/theme names with scope are not allowed" This reverts commit 8426746bf11aa923e8efcf9abb9a6b435b9ba855. --- server/core/helpers/custom-validators/plugins.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/server/core/helpers/custom-validators/plugins.ts b/server/core/helpers/custom-validators/plugins.ts index 521458c83..99ee476b7 100644 --- a/server/core/helpers/custom-validators/plugins.ts +++ b/server/core/helpers/custom-validators/plugins.ts @@ -6,10 +6,6 @@ import { exists, isArray, isSafePath } from './misc.js' const PLUGINS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.PLUGINS -const NPM_VALIDATION_RE = new RegExp( - /^(@[^\._][a-z-_\.~0-9]+\/)?([a-z-0-9]+)$/, -); - function isPluginTypeValid (value: any) { return exists(value) && (value === PluginType.PLUGIN || value === PluginType.THEME) @@ -18,16 +14,14 @@ function isPluginTypeValid (value: any) { function isPluginNameValid (value: string) { return exists(value) && validator.default.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) && - validator.default.matches(value, NPM_VALIDATION_RE) + validator.default.matches(value, /^[a-z-0-9]+$/) } function isNpmPluginNameValid (value: string) { - const match = value.match(NPM_VALIDATION_RE); return exists(value) && validator.default.isLength(value, PLUGINS_CONSTRAINTS_FIELDS.NAME) && - validator.default.matches(value, NPM_VALIDATION_RE) && - (match[2].startsWith("peertube-plugin-") || - match[2].startsWith("peertube-theme-")) + validator.default.matches(value, /^[a-z\-._0-9]+$/) && + (value.startsWith('peertube-plugin-') || value.startsWith('peertube-theme-')) } function isPluginDescriptionValid (value: string) {