@matheusbsbs / matheus-bagliano / commits / db3106b274
Fork 0

send-email: quiet some warnings, reject invalid addresses

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>

Eric Wong committed May 15, 2006 at 02:41 UTC db3106b274a75d5b9ea7f6fe1030b8528df7389b
1 file changed +12 -3
git-send-email.perl
+12 -3
@@ -307,6 +307,10 @@ our ($message_id, $cc, %mail, $subject, $reply_to, $message);
307
308 sub extract_valid_address {
309 my $address = shift;
310 +
311 + # check for a local address:
312 + return $address if ($address =~ /^([\w\-]+)$/);
313 +
314 if ($have_email_valid) {
315 return Email::Valid->address($address);
316 } else {
@@ -498,9 +502,14 @@ sub unique_email_list(@) {
502 my @emails;
503
504 foreach my $entry (@_) {
501 - my $clean = extract_valid_address($entry);
502 - next if $seen{$clean}++;
503 - push @emails, $entry;
505 + if (my $clean = extract_valid_address($entry)) {
506 + $seen{$clean} ||= 0;
507 + next if $seen{$clean}++;
508 + push @emails, $entry;
509 + } else {
510 + print STDERR "W: unable to extract a valid address",
511 + " from: $entry\n";
512 + }
513 }
514 return @emails;
515 }