[pve-devel] [PATCH common 2/2] Fix indexed parameter conversion in documentation

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Apr 19 11:47:55 CEST 2016


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 | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/PVE/RESTHandler.pm b/src/PVE/RESTHandler.pm
index ca3f99b..1823b01 100644
--- a/src/PVE/RESTHandler.pm
+++ b/src/PVE/RESTHandler.pm
@@ -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);
-- 
2.1.4





More information about the pve-devel mailing list