Fix indexed parameter conversion in documentation
authorFabian Gr├╝nbichler <f.gruenbichler@proxmox.com>
Tue, 19 Apr 2016 09:47:55 +0000 (11:47 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 19 Apr 2016 10:29:31 +0000 (12:29 +0200)
this would previously convert properties that matched
'^([a-z]+)(\d+)$' even if they were not part of an indexed
properties series (which always start with 0).

This fixes previously wrongly converted properties:
-smbios1
-server2

src/PVE/RESTHandler.pm

index ca3f99b..1823b01 100644 (file)
@@ -570,8 +570,10 @@ sub usage_str {
        if ($k =~ m/^([a-z]+)(\d+)$/) {
            my $name = $1;
            next if $idx_param->{$name};
-           $idx_param->{$name} = 1;
-           $base = "${name}[n]";
+           if ($2 == 0) {
+               $idx_param->{$name} = 1;
+               $base = "${name}[n]";
+           }
        }
 
        my $mapping = defined($stringfilemap) ? &$stringfilemap($name) : undef;
@@ -634,8 +636,10 @@ sub dump_properties {
        if ($k =~ m/^([a-z]+)(\d+)$/) {
            my $name = $1;
            next if $idx_param->{$name};
-           $idx_param->{$name} = 1;
-           $base = "${name}[n]";
+           if ($2 == 0) {
+               $idx_param->{$name} = 1;
+               $base = "${name}[n]";
+           }
        }
 
        $raw .= &$get_property_description($base, $style, $phash, $format, 0);