]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/RESTHandler.pm
Inotify: read_interfaces : remove trailing whitespaces
[pve-common.git] / src / PVE / RESTHandler.pm
index 04b07730fa98af4822fdd8c78c9c9084188c2756..60731acf11375a3db1b8d57af91e5834753dd3ea 100644 (file)
@@ -242,6 +242,9 @@ sub register_method {
        $errprefix = "register method ${self}/$info->{path} -";
        $info->{method} = 'GET' if !$info->{method};
        $method = $info->{method};
+
+       # apply default value
+       $info->{allowtoken} = 1 if !defined($info->{allowtoken});
     }
 
     $method_path_lookup->{$self} = {} if !defined($method_path_lookup->{$self});
@@ -438,7 +441,11 @@ sub handle {
        # untaint data (already validated)
        my $extra = delete $param->{'extra-args'};
        while (my ($key, $val) = each %$param) {
-           ($param->{$key}) = $val =~ /^(.*)$/s;
+           if (defined($val)) {
+               ($param->{$key}) = $val =~ /^(.*)$/s;
+           } else {
+               $param->{$key} = undef;
+           }
        }
        $param->{'extra-args'} = [map { /^(.*)$/ } @$extra] if $extra;
     }
@@ -614,7 +621,10 @@ sub getopt_usage {
 
     my $schema = $info->{parameters};
     my $name = $info->{name};
-    my $prop = { %{$schema->{properties}} }; # copy
+    my $prop =  {};
+    if ($schema->{properties}) {
+       $prop = { %{$schema->{properties}} }; # copy
+    }
 
     my $has_output_format_option = $formatter_properties->{'output-format'} ? 1 : 0;