[pve-devel] [PATCH pve-common 2/3 v2] Make configid regex public
Dominic Jäger
d.jaeger at proxmox.com
Wed Oct 28 11:04:53 CET 2020
Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
---
v1->v2: Didn't exist
src/PVE/JSONSchema.pm | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index e8d7395..29ada5b 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -21,6 +21,8 @@ parse_property_string
register_standard_option
);
+our $CONFIGID_RE = qr/[a-z][a-z0-9_-]+/i;
+
# Note: This class implements something similar to JSON schema, but it is not 100% complete.
# see: http://tools.ietf.org/html/draft-zyp-json-schema-02
# see: http://json-schema.org/
@@ -177,7 +179,7 @@ register_format('pve-configid', \&pve_verify_configid);
sub pve_verify_configid {
my ($id, $noerr) = @_;
- if ($id !~ m/^[a-z][a-z0-9_-]+$/i) {
+ if ($id !~ m/^$CONFIGID_RE$/) {
return undef if $noerr;
die "invalid configuration ID '$id'\n";
}
--
2.20.1
More information about the pve-devel
mailing list