summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-11-29 13:27:54 -0800
committerJunio C Hamano <gitster@pobox.com>2016-11-29 13:27:55 -0800
commita3f2781dd0c295b5be2c0b42776f806d4f40df05 (patch)
tree10b756e891ea251d1cafb44e392991805497c61b /perl
parentfa308cd8487f9619f9002ab4775e463b35fad722 (diff)
parentdcfafc5214e6af277aa8565af4f63b20046d65bf (diff)
downloadgit-a3f2781dd0c295b5be2c0b42776f806d4f40df05.tar.gz
Merge branch 'mm/send-email-cc-cruft-after-address' into maint
"git send-email" attempts to pick up valid e-mails from the trailers, but people in real world write non-addresses there, like "Cc: Stable <add@re.ss> # 4.8+", which broke the output depending on the availability and vintage of Mail::Address perl module. * mm/send-email-cc-cruft-after-address: Git.pm: add comment pointing to t9000 t9000-addresses: update expected results after fix parse_mailboxes: accept extra text after <...> address
Diffstat (limited to 'perl')
-rw-r--r--perl/Git.pm15
1 files changed, 9 insertions, 6 deletions
diff --git a/perl/Git.pm b/perl/Git.pm
index ce7e4e8da3..864123fe8e 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -871,6 +871,8 @@ Return an array of mailboxes extracted from a string.
=cut
+# Very close to Mail::Address's parser, but we still have minor
+# differences in some cases (see t9000 for examples).
sub parse_mailboxes {
my $re_comment = qr/\((?:[^)]*)\)/;
my $re_quote = qr/"(?:[^\"\\]|\\.)*"/;
@@ -879,6 +881,7 @@ sub parse_mailboxes {
# divide the string in tokens of the above form
my $re_token = qr/(?:$re_quote|$re_word|$re_comment|\S)/;
my @tokens = map { $_ =~ /\s*($re_token)\s*/g } @_;
+ my $end_of_addr_seen = 0;
# add a delimiter to simplify treatment for the last mailbox
push @tokens, ",";
@@ -888,10 +891,10 @@ sub parse_mailboxes {
if ($token =~ /^[,;]$/) {
# if buffer still contains undeterminated strings
# append it at the end of @address or @phrase
- if (@address) {
- push @address, @buffer;
- } else {
+ if ($end_of_addr_seen) {
push @phrase, @buffer;
+ } else {
+ push @address, @buffer;
}
my $str_phrase = join ' ', @phrase;
@@ -915,16 +918,16 @@ sub parse_mailboxes {
push @addr_list, $str_mailbox if ($str_mailbox);
@phrase = @address = @comment = @buffer = ();
+ $end_of_addr_seen = 0;
} elsif ($token =~ /^\(/) {
push @comment, $token;
} elsif ($token eq "<") {
push @phrase, (splice @address), (splice @buffer);
} elsif ($token eq ">") {
+ $end_of_addr_seen = 1;
push @address, (splice @buffer);
- } elsif ($token eq "@") {
+ } elsif ($token eq "@" && !$end_of_addr_seen) {
push @address, (splice @buffer), "@";
- } elsif ($token eq ".") {
- push @address, (splice @buffer), ".";
} else {
push @buffer, $token;
}