]> git.proxmox.com Git - pve-common.git/commitdiff
schema: check format: parse list formats as arrays
authorFabian Ebner <f.ebner@proxmox.com>
Thu, 18 Mar 2021 08:44:18 +0000 (09:44 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 3 May 2021 11:05:20 +0000 (13:05 +0200)
Previously, the returned value would be only the last element or undef in case
of an empty list. There's only a handful of callers of check_format() that look
at the return value and AFAICT none of the exisitng ones is for a -list format.
But best to avoid any future surprises.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
src/PVE/JSONSchema.pm

index f1f90ff38165a199b4dcaa2f87d54a38b31249bd..6297fff0e24abe6f3f79b98e8c2484ef007b0545 100644 (file)
@@ -714,9 +714,10 @@ sub check_format {
        if $format_type ne 'none' && ref($registered) ne 'CODE';
 
     if ($format_type eq 'list') {
+       $parsed = [];
        # Note: we allow empty lists
        foreach my $v (split_list($value)) {
-           $parsed = $registered->($v);
+           push @{$parsed}, $registered->($v);
        }
     } elsif ($format_type eq 'opt') {
        $parsed = $registered->($value) if $value;