From c77b4c9640f3a3bf0108a2692b0975681bb60879 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 18 Mar 2016 11:38:24 +0100 Subject: [PATCH] add the 'urlencoded' string format --- src/PVE/JSONSchema.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm index 8cb07e1..7716ed3 100644 --- a/src/PVE/JSONSchema.pm +++ b/src/PVE/JSONSchema.pm @@ -110,6 +110,16 @@ sub get_format { register_format('string', sub {}); # allow format => 'string-list' +register_format('urlencoded', \&pve_verify_urlencoded); +sub pve_verify_urlencoded { + my ($text, $noerr) = @_; + if ($text !~ /^[-%a-zA-Z0-9_.!~*'()]*$/) { + return undef if $noerr; + die "invalid urlencoded string: $text\n"; + } + return $text; +} + register_format('pve-configid', \&pve_verify_configid); sub pve_verify_configid { my ($id, $noerr) = @_; -- 2.39.2