mirror of
https://github.com/git/git.git
synced 2024-11-17 22:44:49 +01:00
Merge branch 'vb/sendemail' into next
* vb/sendemail: send-email: be more lenient and just catch obvious mistakes.
This commit is contained in:
commit
9c41a17ca2
1 changed files with 6 additions and 4 deletions
|
@ -312,16 +312,18 @@ sub expand_aliases {
|
||||||
|
|
||||||
sub extract_valid_address {
|
sub extract_valid_address {
|
||||||
my $address = shift;
|
my $address = shift;
|
||||||
|
my $local_part_regexp = '[^<>"\s@]+';
|
||||||
|
my $domain_regexp = '[^.<>"\s@]+\.[^<>"\s@]+';
|
||||||
|
|
||||||
# check for a local address:
|
# check for a local address:
|
||||||
return $address if ($address =~ /^([\w\-.]+)$/);
|
return $address if ($address =~ /^($local_part_regexp)$/);
|
||||||
|
|
||||||
if ($have_email_valid) {
|
if ($have_email_valid) {
|
||||||
return Email::Valid->address($address);
|
return scalar Email::Valid->address($address);
|
||||||
} else {
|
} else {
|
||||||
# less robust/correct than the monster regexp in Email::Valid,
|
# less robust/correct than the monster regexp in Email::Valid,
|
||||||
# but still does a 99% job, and one less dependency
|
# but still does a 99% job, and one less dependency
|
||||||
$address =~ /([\w\-.]+@[\w\-.]+)/;
|
$address =~ /($local_part_regexp\@$domain_regexp)/;
|
||||||
return $1;
|
return $1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,7 +386,7 @@ sub send_message
|
||||||
defined $pid or die $!;
|
defined $pid or die $!;
|
||||||
if (!$pid) {
|
if (!$pid) {
|
||||||
exec($smtp_server,'-i',
|
exec($smtp_server,'-i',
|
||||||
map { scalar extract_valid_address($_) }
|
map { extract_valid_address($_) }
|
||||||
@recipients) or die $!;
|
@recipients) or die $!;
|
||||||
}
|
}
|
||||||
print $sm "$header\n$message";
|
print $sm "$header\n$message";
|
||||||
|
|
Loading…
Reference in a new issue