[pve-devel] [PATCH common 4/4] add the 'urlencoded' string format

Wolfgang Bumiller w.bumiller at proxmox.com
Fri Mar 18 11:38:24 CET 2016


---
 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.1.4





More information about the pve-devel mailing list