From 599d6fb77b7691c1f4e023b37f7afd9f6e3de213 Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Wed, 26 Oct 2022 23:31:40 -0500 Subject: [PATCH] Factor email address collection out of directive-scanning loop --- gatekeeper.pl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gatekeeper.pl b/gatekeeper.pl index 6a1af55..1a002f1 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -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() -- 2.25.1