Skip to content

Commit b5e112d

Browse files
Awaryngitster
authored andcommitted
send-email: refactor address list process
Simplify code by creating a function which transform a list of strings containing email addresses (separated by commas, comporting aliases) into a clean list of valid email addresses. Signed-off-by: Remi Lespinet <[email protected]> Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d4cf11c commit b5e112d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

git-send-email.perl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -808,12 +808,9 @@ sub expand_one_alias {
808808
return $aliases{$alias} ? expand_aliases(@{$aliases{$alias}}) : $alias;
809809
}
810810

811-
@initial_to = expand_aliases(@initial_to);
812-
@initial_to = validate_address_list(sanitize_address_list(@initial_to));
813-
@initial_cc = expand_aliases(@initial_cc);
814-
@initial_cc = validate_address_list(sanitize_address_list(@initial_cc));
815-
@bcclist = expand_aliases(@bcclist);
816-
@bcclist = validate_address_list(sanitize_address_list(@bcclist));
811+
@initial_to = process_address_list(@initial_to);
812+
@initial_cc = process_address_list(@initial_cc);
813+
@bcclist = process_address_list(@bcclist);
817814

818815
if ($thread && !defined $initial_reply_to && $prompting) {
819816
$initial_reply_to = ask(
@@ -1026,6 +1023,13 @@ sub sanitize_address_list {
10261023
return (map { sanitize_address($_) } @_);
10271024
}
10281025

1026+
sub process_address_list {
1027+
my @addr_list = expand_aliases(@_);
1028+
@addr_list = sanitize_address_list(@addr_list);
1029+
@addr_list = validate_address_list(@addr_list);
1030+
return @addr_list;
1031+
}
1032+
10291033
# Returns the local Fully Qualified Domain Name (FQDN) if available.
10301034
#
10311035
# Tightly configured MTAa require that a caller sends a real DNS
@@ -1535,10 +1539,8 @@ sub send_message {
15351539
($confirm =~ /^(?:auto|compose)$/ && $compose && $message_num == 1));
15361540
$needs_confirm = "inform" if ($needs_confirm && $confirm_unconfigured && @cc);
15371541

1538-
@to = expand_aliases(@to);
1539-
@to = validate_address_list(sanitize_address_list(@to));
1540-
@cc = expand_aliases(@cc);
1541-
@cc = validate_address_list(sanitize_address_list(@cc));
1542+
@to = process_address_list(@to);
1543+
@cc = process_address_list(@cc);
15421544

15431545
@to = (@initial_to, @to);
15441546
@cc = (@initial_cc, @cc);

0 commit comments

Comments
 (0)