Interfaces/Other Types/VLAN - constraint user input further for https://github.com/opnsense/core/issues/6038 to avoid future naming collisions.

This commit is contained in:
Ad Schellevis 2022-10-01 09:42:01 +02:00
parent 4f9e12c999
commit 2d74c6b641

View File

@ -53,12 +53,19 @@ class Vlan extends BaseModel
break;
} elseif (!(strpos((string)$node, (string)$prefix) === 0)) {
$messages->appendMessage(new Message(
sprintf(gettext("device name does not match type (e.g. %s_xxx)."), (string)$prefix),
sprintf(gettext("Device name does not match type (e.g. %s0XXX)."), (string)$prefix),
$key
));
} elseif (!preg_match("/^([a-zA-Z0-9_]){1,16}$/", (string)$node)) {
} elseif (!preg_match("/^{$prefix}0([0-9\.]){1,16}$/", (string)$node)) {
$messages->appendMessage(new Message(
gettext("Invalid device name, only up to 16 alphanumeric characters are supported."),
sprintf(
gettext(
"A maximum of 16 characters is allowed starting with %s0 combined with ".
"numeric characters and dots[.], e.g. (%s.1.104)"
),
$prefix,
$prefix
),
$key
));
}