Factor email address collection out of directive-scanning loop
authorJacob Bachmeyer <jcb@gnu.org>
Thu, 27 Oct 2022 04:31:40 +0000 (23:31 -0500)
committerJacob Bachmeyer <jcb@gnu.org>
Thu, 27 Oct 2022 04:31:40 +0000 (23:31 -0500)
gatekeeper.pl

index 6a1af5546ba9421194d1b8a1e4d6d220b5768698..1a002f1f9f30f493dc4dbc90789199da0e259773 100755 (executable)
@@ -1709,16 +1709,6 @@ sub interpret_directive {
       $header{package} = $dirs[0];     # top-level name, no subdir
       $info{directory} = $header{directory};
       $info{package} = $header{package};
-
-      # TODO: move this part elsewhere:
-      # Set email addresses
-      my @a = email_addresses($info{package});
-      foreach my $address (@a) {
-       # Do not include duplicates
-       push (@{$info{email}}, $address)
-         unless (grep($_ eq $address,@{$info{email}}) > 0);
-      }
-
     } elsif ($tainted_cmd eq 'filename') {
       # We use the same filename restrictions as scan_incoming
       unless ($tainted_val =~ /^($RE_filename_here)$/) {
@@ -1794,6 +1784,16 @@ sub interpret_directive {
       { push @ops, ($install = [install => $header{filename}]) }
   }
 
+  # Set email addresses
+  if (defined $header{package}) {
+    my @a = email_addresses($header{package});
+    foreach my $address (@a) {
+      # Do not include duplicates
+      push (@{$info{email}}, $address)
+       unless (grep($_ eq $address,@{$info{email}}) > 0);
+    }
+  }
+
   if (@errors) {
     # TODO:  eventually report all errors found
     # for now, just report the first error, to emulate an immediate fatal()