From 6c3a1ae8e560eb09a3989be41646416ceb937ab8 Mon Sep 17 00:00:00 2001 From: Yufeng He <40085740+he-yufeng@users.noreply.github.com> Date: Sun, 14 Jun 2026 10:57:13 +0800 Subject: [PATCH] fix: sanitize generated platform ids (#8768) --- .../src/components/platform/AddNewPlatform.vue | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dashboard/src/components/platform/AddNewPlatform.vue b/dashboard/src/components/platform/AddNewPlatform.vue index c802f5499..1b57c2eac 100644 --- a/dashboard/src/components/platform/AddNewPlatform.vue +++ b/dashboard/src/components/platform/AddNewPlatform.vue @@ -1409,6 +1409,13 @@ export default { return suffix; }, + sanitizePlatformIdPart(value) { + return String(value || "") + .trim() + .replace(/\s+/g, "") + .replace(/[!:]/g, "_"); + }, + handlePlatformRegistrationCreated(data) { if (!this.selectedPlatformConfig || !data) { return; @@ -1420,18 +1427,14 @@ export default { } let suffix = ""; - const explicitSuffix = String(data.platform_id_suffix || "") - .trim() - .replace(/[!:]/g, "_"); + const explicitSuffix = this.sanitizePlatformIdPart(data.platform_id_suffix); if (explicitSuffix) { suffix = explicitSuffix.startsWith("_") || explicitSuffix.startsWith("-") ? explicitSuffix : `_${explicitSuffix}`; } else if (data.bot_name) { - const safeBotName = String(data.bot_name || "") - .trim() - .replace(/[!:]/g, "_"); + const safeBotName = this.sanitizePlatformIdPart(data.bot_name); if (safeBotName) { suffix = `-${safeBotName}`; } @@ -1459,7 +1462,7 @@ export default { if (!id) { return false; } - return !/[!:]/.test(id); + return !/[!:\s]/.test(id); }, // 获取该平台适配器使用的所有配置文件(新版本:直接操作路由表)