]> git.proxmox.com Git - pve-common.git/commitdiff
add the 'urlencoded' string format
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 18 Mar 2016 10:38:24 +0000 (11:38 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 21 Mar 2016 07:09:22 +0000 (08:09 +0100)
src/PVE/JSONSchema.pm

index 8cb07e12c5d7520fd8b4fb1a92e2cda5b2c0ce25..7716ed360d2a8b1652f90c0eeb098e79d3c51e30 100644 (file)
@@ -110,6 +110,16 @@ sub get_format {
 
 register_format('string', sub {}); # allow format => 'string-list'
 
 
 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) = @_;
 register_format('pve-configid', \&pve_verify_configid);
 sub pve_verify_configid {
     my ($id, $noerr) = @_;