From 0055e9b2c46b39b667a13c2836573dfc8b220360 Mon Sep 17 00:00:00 2001 From: Michal Fox Date: Sat, 3 Oct 2026 01:29:24 +0200 Subject: [PATCH] fix #7586: notification: check names of matchers and targets in the UI The names of notification matchers and targets have to be safe IDs, but only the name of webhook targets was checked in the UI, and that without saying what is wrong. For all others, an invalid name, for example one containing a space, was only rejected by the API with a 'parameter verification errors (400)' message, without saying which characters are allowed. Add a 'SafeId' vtype, which uses the existing safe ID regex and says which characters are allowed, and use it for the names of matchers and all target types. Signed-off-by: Michal Fox --- src/Toolkit.js | 9 +++++++++ src/panel/GotifyEditPanel.js | 1 + src/panel/SendmailEditPanel.js | 1 + src/panel/SmtpEditPanel.js | 1 + src/panel/WebhookEditPanel.js | 2 +- src/window/NotificationMatcherEdit.js | 1 + 6 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Toolkit.js b/src/Toolkit.js index bd31b3c..c1594b7 100644 --- a/src/Toolkit.js +++ b/src/Toolkit.js @@ -134,6 +134,15 @@ Ext.apply(Ext.form.field.VTypes, { ': ' + gettext('letter'), + SafeId: function (v) { + return Proxmox.Utils.safeIdRegex.test(v); + }, + SafeIdText: + gettext('Allowed characters') + + ": 'A-Z', 'a-z', '0-9', '_', '-', '.'
" + + gettext('Must start with') + + ": 'A-Z', 'a-z', '0-9', '_'", + HttpProxy: function (v) { return /^http:\/\/.*$/.test(v); }, diff --git a/src/panel/GotifyEditPanel.js b/src/panel/GotifyEditPanel.js index 5e78e73..3e12323 100644 --- a/src/panel/GotifyEditPanel.js +++ b/src/panel/GotifyEditPanel.js @@ -15,6 +15,7 @@ Ext.define('Proxmox.panel.GotifyEditPanel', { editable: '{isCreate}', }, fieldLabel: gettext('Endpoint Name'), + vtype: 'SafeId', allowBlank: false, }, { diff --git a/src/panel/SendmailEditPanel.js b/src/panel/SendmailEditPanel.js index a4de50c..81624ad 100644 --- a/src/panel/SendmailEditPanel.js +++ b/src/panel/SendmailEditPanel.js @@ -26,6 +26,7 @@ Ext.define('Proxmox.panel.SendmailEditPanel', { editable: '{isCreate}', }, fieldLabel: gettext('Endpoint Name'), + vtype: 'SafeId', allowBlank: false, }, { diff --git a/src/panel/SmtpEditPanel.js b/src/panel/SmtpEditPanel.js index 37e4d51..8fafba9 100644 --- a/src/panel/SmtpEditPanel.js +++ b/src/panel/SmtpEditPanel.js @@ -51,6 +51,7 @@ Ext.define('Proxmox.panel.SmtpEditPanel', { editable: '{isCreate}', }, fieldLabel: gettext('Endpoint Name'), + vtype: 'SafeId', allowBlank: false, }, { diff --git a/src/panel/WebhookEditPanel.js b/src/panel/WebhookEditPanel.js index 7980d8b..8854329 100644 --- a/src/panel/WebhookEditPanel.js +++ b/src/panel/WebhookEditPanel.js @@ -17,7 +17,7 @@ Ext.define('Proxmox.panel.WebhookEditPanel', { editable: '{isCreate}', }, fieldLabel: gettext('Endpoint Name'), - regex: Proxmox.Utils.safeIdRegex, + vtype: 'SafeId', allowBlank: false, }, ], diff --git a/src/window/NotificationMatcherEdit.js b/src/window/NotificationMatcherEdit.js index a1d173c..d1b66a3 100644 --- a/src/window/NotificationMatcherEdit.js +++ b/src/window/NotificationMatcherEdit.js @@ -12,6 +12,7 @@ Ext.define('Proxmox.panel.NotificationMatcherGeneralPanel', { editable: '{isCreate}', }, fieldLabel: gettext('Matcher Name'), + vtype: 'SafeId', allowBlank: false, }, {