summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-06-06 23:42:33 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-06-06 23:42:33 (GMT)
commitad0e0b0a31c4e7a7a893ea68fd4ee92aebb79988 (patch)
tree1bb4739962e8050dcd622d2563ba7ce0af31566d
parent3026402cbc60c003c4bc043368afc619e4d9b3cd (diff)
parent09302e177e8dc789c03d9df3620e12e095b4acfb (diff)
downloadgit-ad0e0b0a31c4e7a7a893ea68fd4ee92aebb79988.zip
git-ad0e0b0a31c4e7a7a893ea68fd4ee92aebb79988.tar.gz
git-ad0e0b0a31c4e7a7a893ea68fd4ee92aebb79988.tar.bz2
Merge branch 'vb/sendemail'
* vb/sendemail: send-email: a bit more careful domain regexp. send-email: be more lenient and just catch obvious mistakes. Cleanup git-send-email.perl:extract_valid_email
-rwxr-xr-xgit-send-email.perl15
1 files changed, 7 insertions, 8 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index ed1d89b..7b1cca7 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -312,20 +312,19 @@ our ($message_id, $cc, %mail, $subject, $reply_to, $references, $message);
sub extract_valid_address {
my $address = shift;
+ my $local_part_regexp = '[^<>"\s@]+';
+ my $domain_regexp = '[^.<>"\s@]+(?:\.[^.<>"\s@]+)+';
# check for a local address:
- return $address if ($address =~ /^([\w\-]+)$/);
+ return $address if ($address =~ /^($local_part_regexp)$/);
if ($have_email_valid) {
- return Email::Valid->address($address);
+ return scalar Email::Valid->address($address);
} else {
# less robust/correct than the monster regexp in Email::Valid,
# but still does a 99% job, and one less dependency
- my $cleaned_address;
- if ($address =~ /([^\"<>\s]+@[^<>\s]+)/) {
- $cleaned_address = $1;
- }
- return $cleaned_address;
+ $address =~ /($local_part_regexp\@$domain_regexp)/;
+ return $1;
}
}
@@ -387,7 +386,7 @@ X-Mailer: git-send-email $gitversion
defined $pid or die $!;
if (!$pid) {
exec($smtp_server,'-i',
- map { scalar extract_valid_address($_) }
+ map { extract_valid_address($_) }
@recipients) or die $!;
}
print $sm "$header\n$message";