]> git.proxmox.com Git - pve-common.git/commitdiff
follouwp: improve comment detection and refactor slightly
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 26 Jun 2020 07:55:21 +0000 (09:55 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 26 Jun 2020 07:55:21 +0000 (09:55 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/JSONSchema.pm

index 15a498c019293682b7639aecc850d5021c4e4047..275c20adc74f86cd37b92a63df3d6b955a11edae 100644 (file)
@@ -486,19 +486,19 @@ register_format('timezone', \&pve_verify_timezone);
 sub pve_verify_timezone {
     my ($timezone, $noerr) = @_;
 
-    my $zonetab = "/usr/share/zoneinfo/zone.tab";
     return $timezone if $timezone eq 'UTC';
-    open(my $fh, "<", $zonetab);
-    while(my $line = <$fh>) {
-       next if $line =~ /^#/;
+
+    open(my $fh, "<",  "/usr/share/zoneinfo/zone.tab");
+    while (my $line = <$fh>) {
+       next if $line =~ /^\s*#/;
        chomp $line;
-       return $timezone if $timezone eq (split /\t/, $line)[2]; # found
+       my $zone = (split /\t/, $line)[2];
+       return $timezone if $timezone eq $zone; # found
     }
     close $fh;
 
     return undef if $noerr;
     die "invalid time zone '$timezone'\n";
-
 }
 
 # network interface name