Skip to content

Commit

Permalink
send-email: quiet some warnings, reject invalid addresses
Browse files Browse the repository at this point in the history
I'm not sure why we never actually rejected invalid addresses in
the first place.  We just seemed to be using our email validity
checkers to kill duplicates.

Now we just drop invalid email addresses completely and warn
the user about it.

Since we support local sendmail, we'll also accept username-only
addresses.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Eric Wong authored and Junio C Hamano committed May 15, 2006
1 parent aca7ad7 commit db3106b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ sub expand_aliases {

sub extract_valid_address {
my $address = shift;

# check for a local address:
return $address if ($address =~ /^([\w\-]+)$/);

if ($have_email_valid) {
return Email::Valid->address($address);
} else {
Expand Down Expand Up @@ -498,9 +502,14 @@ (@)
my @emails;

foreach my $entry (@_) {
my $clean = extract_valid_address($entry);
next if $seen{$clean}++;
push @emails, $entry;
if (my $clean = extract_valid_address($entry)) {
$seen{$clean} ||= 0;
next if $seen{$clean}++;
push @emails, $entry;
} else {
print STDERR "W: unable to extract a valid address",
" from: $entry\n";
}
}
return @emails;
}

0 comments on commit db3106b

Please sign in to comment.