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 <me@dualfroz.com>
This commit is contained in:
1 parent
060e0c6fa9
commit
0055e9b2c4
6 files changed
+14
-1
No files matched your search
@@ -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', '_', '-', '.'<br />" +
|
||||
gettext('Must start with') +
|
||||
": 'A-Z', 'a-z', '0-9', '_'",
|
||||
|
||||
HttpProxy: function (v) {
|
||||
return /^http:\/\/.*$/.test(v);
|
||||
},
|
||||
|
||||
@@ -15,6 +15,7 @@ Ext.define('Proxmox.panel.GotifyEditPanel', {
|
||||
editable: '{isCreate}',
|
||||
},
|
||||
fieldLabel: gettext('Endpoint Name'),
|
||||
vtype: 'SafeId',
|
||||
allowBlank: false,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ Ext.define('Proxmox.panel.SendmailEditPanel', {
|
||||
editable: '{isCreate}',
|
||||
},
|
||||
fieldLabel: gettext('Endpoint Name'),
|
||||
vtype: 'SafeId',
|
||||
allowBlank: false,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -51,6 +51,7 @@ Ext.define('Proxmox.panel.SmtpEditPanel', {
|
||||
editable: '{isCreate}',
|
||||
},
|
||||
fieldLabel: gettext('Endpoint Name'),
|
||||
vtype: 'SafeId',
|
||||
allowBlank: false,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ Ext.define('Proxmox.panel.WebhookEditPanel', {
|
||||
editable: '{isCreate}',
|
||||
},
|
||||
fieldLabel: gettext('Endpoint Name'),
|
||||
regex: Proxmox.Utils.safeIdRegex,
|
||||
vtype: 'SafeId',
|
||||
allowBlank: false,
|
||||
},
|
||||
],
|
||||
|
||||
@@ -12,6 +12,7 @@ Ext.define('Proxmox.panel.NotificationMatcherGeneralPanel', {
|
||||
editable: '{isCreate}',
|
||||
},
|
||||
fieldLabel: gettext('Matcher Name'),
|
||||
vtype: 'SafeId',
|
||||
allowBlank: false,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user