ui: improve ZFS pool name validator accuracy

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-11-19 15:56:42 +01:00
parent a75caed794
commit f39b06d7fa

View File

@ -46,10 +46,17 @@ Ext.define('PVE.node.CreateZFS', {
name: 'name', name: 'name',
fieldLabel: gettext('Name'), fieldLabel: gettext('Name'),
allowBlank: false, allowBlank: false,
maxLength: 128, // ZFS_MAX_DATASET_NAME_LEN is (256 - some edge case)
validator: v => {
// see zpool_name_valid function in libzfs_zpool.c // see zpool_name_valid function in libzfs_zpool.c
validator: v => v.match(/^(mirror|raidz|draid|spare)/) || v === 'log' if (v.match(/^(mirror|raidz|draid|spare)/) || v === 'log') {
? gettext('Cannot use reserved pool name') return gettext('Cannot use reserved pool name');
: true, } else if (!v.match(/^[a-zA-Z][a-zA-Z0-9\-_.]*$/)) {
// note: zfs would support also : and whitespace, but we don't
return gettext("Invalid characters in pool name");
}
return true;
},
}, },
{ {
xtype: 'proxmoxcheckbox', xtype: 'proxmoxcheckbox',