From: Wolfgang Bumiller Date: Wed, 22 Mar 2017 11:53:33 +0000 (+0100) Subject: forbid trailing commas in lists X-Git-Url: https://git.proxmox.com/?p=pve-firewall.git;a=commitdiff_plain;h=55b473712ee43781b203c72b36fcdba82d608cd5 forbid trailing commas in lists iptables-restore doesn't allow them --- diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm index c7d90f8..0535d78 100644 --- a/src/PVE/Firewall.pm +++ b/src/PVE/Firewall.pm @@ -976,7 +976,9 @@ sub parse_address_list { my $iprange = 0; my $ipversion; - foreach my $elem (split(/,/, $str)) { + my @elements = split(/,/, $str); + die "extraneous commas in list\n" if $str ne join(',', @elements); + foreach my $elem (@elements) { $count++; my $ip = Net::IP->new($elem); if (!$ip) { @@ -1005,7 +1007,9 @@ sub parse_port_name_number_or_range { my $count = 0; my $icmp_port = 0; - foreach my $item (split(/,/, $str)) { + my @elements = split(/,/, $str); + die "extraneous commas in list\n" if $str ne join(',', @elements); + foreach my $item (@elements) { $count++; if ($item =~ m/^(\d+):(\d+)$/) { my ($port1, $port2) = ($1, $2);