git-svn: rebuild convenience and bugfixes
[gitweb.git] / git-send-email.perl
index ed1d89b3f73564715d0fe4061e87f63fea7e7be2..7b1cca70abcfcbf12c171c91d3f71ad4e43b0474 100755 (executable)
@@ -312,20 +312,19 @@ sub expand_aliases {
 
 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 @@ sub send_message
                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";