The regex in JSONSchema::parse_id requires at least 2 characters, but shorter IDs only failed with "contains illegal characters". Add explicit length check to return a clearer error message in this case.
Signed-off-by: Arthur Bied-Charreton <[email protected]> --- src/PVE/JSONSchema.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm index 0c9bb82..17e7126 100644 --- a/src/PVE/JSONSchema.pm +++ b/src/PVE/JSONSchema.pm @@ -289,6 +289,11 @@ sub parse_acme_plugin_id { sub parse_id { my ($id, $type, $noerr) = @_; + if (length($id) < 2) { + return undef if $noerr; + die "$type ID '$id' cannot be shorter than 2 characters\n"; + } + if ($id !~ m/^[a-z][a-z0-9\-\_\.]*[a-z0-9]$/i) { return undef if $noerr; die "$type ID '$id' contains illegal characters\n"; -- 2.47.3 _______________________________________________ pve-devel mailing list [email protected] https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
