From: Jacob Bachmeyer Date: Fri, 28 Oct 2022 23:46:23 +0000 (-0500) Subject: Revise directory_email_addresses X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=27e2a34c7d71ee870ea2823bb434d3ed95eb2928;p=gatekeeper.git Revise directory_email_addresses Addresses are now collected in an array; repeated addresses are accepted at this stage, and filtered out in the mail function. --- diff --git a/gatekeeper.pl b/gatekeeper.pl index 3c3fdb6..acfd832 100755 --- a/gatekeeper.pl +++ b/gatekeeper.pl @@ -931,13 +931,6 @@ sub directory_email_addresses { my @directory = File::Spec::Unix->splitdir($directory); my $package_name = $directory[0]; - # Quote this once here to avoid recompiling the pattern for each line of - # the maintainers.bypkg file; the \Q and \E are probably not needed, - # since package names should not contain regex metacharacters but are an - # extra protection measure, in case a package name contains "+" or so. - my $package_name_re = qr/^\Q$package_name\E\s+-\s+/; - - my %addresses; my @email_files = directory_configuration_files('email', $directory); @@ -956,28 +949,33 @@ package. END unless -f File::Spec->catfile($package_config_base, $package_name, 'email'); + my @addresses; + foreach my $file (@email_files) { open EMAIL_FILE, '<', $file or ftp_abort("open($file) failed: $!"); while () { chomp; - $addresses{$1}++ + push @addresses, $1 if m/^([[:graph:]]+[@][[:graph:]]+)$/; # simple sanity check and untaint } close EMAIL_FILE or ftp_warn("close($file) failed: $!"); } # Now also look for all maintainer addresses in the maintainers.bypkg file + my $needle = $package_name.' - '; + my $nlen = length $needle; open EMAIL_FILE, '<', $maintainers_bypkg or ftp_abort("open($maintainers_bypkg) failed: $!"); while () { chomp; - next unless m/$package_name_re/g; # find the line for this package + next unless $needle eq substr $_,0,$nlen; # find the line for this package # crawl through it, collecting email addresses - $addresses{$1}++ while m/\G[^<]*<([^@]+[@][^>]+)>/g; + pos = $nlen; + push @addresses, $1 while m/\G[^<]*<([^@]+[@][^>]+)>/g; } close EMAIL_FILE or ftp_warn("close($maintainers_bypkg) failed: $!"); - return keys %addresses; + return @addresses; }