From: Wolfgang Bumiller Date: Fri, 18 Mar 2016 10:38:24 +0000 (+0100) Subject: add the 'urlencoded' string format X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=c77b4c9640f3a3bf0108a2692b0975681bb60879 add the 'urlencoded' string format --- 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) = @_;