From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: gitster@pobox.com
Cc: git@vger.kernel.org, Larry Finger <Larry.Finger@lwfinger.net>,
Jeff King <peff@peff.net>,
Mathieu Lienard--Mayor <Mathieu.Lienard--Mayor@ensimag.imag.fr>,
Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>,
Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [PATCH] parse_mailboxes: accept extra text after <...> address
Date: Thu, 13 Oct 2016 07:47:27 +0200 [thread overview]
Message-ID: <20161013054727.13402-1-Matthieu.Moy@imag.fr> (raw)
In-Reply-To: <vpqmvi8n71g.fsf@anie.imag.fr>
The test introduced in this commit succeeds without the patch to Git.pm
if Mail::Address is installed, but fails otherwise because our in-house
parser does not accept any text after the email address. They succeed
both with and without Mail::Address after this commit.
Mail::Address accepts extra text and considers it as part of the name,
iff the address is surrounded with <...>. The implementation mimics
this behavior as closely as possible.
This mostly restores the behavior we had before b1c8a11 (send-email:
allow multiple emails using --cc, --to and --bcc, 2015-06-30), but we
keep the possibility to handle comma-separated lists.
Reported-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
perl/Git.pm | 13 +++++++------
t/t9001-send-email.sh | 29 +++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index ce7e4e8da394..ca769246216c 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -879,6 +879,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 +889,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 +916,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;
}
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index b3355d2c7016..3dc4a3454d22 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -140,6 +140,35 @@ test_expect_success $PREREQ 'Verify commandline' '
test_cmp expected commandline1
'
+test_expect_success $PREREQ 'setup expect for cc trailer' "
+cat >expected-cc <<\EOF
+!recipient@example.com!
+!author@example.com!
+!one@example.com!
+!two@example.com!
+!three@example.com!
+!four@example.com!
+!five@example.com!
+EOF
+"
+
+test_expect_success $PREREQ 'cc trailer with various syntax' '
+ test_commit cc-trailer &&
+ test_when_finished "git reset --hard HEAD^" &&
+ git commit --amend -F - <<-EOF &&
+ Test Cc: trailers.
+
+ Cc: one@example.com
+ Cc: <two@example.com> # this is part of the name
+ Cc: <three@example.com>, <four@example.com> # not.five@example.com
+ Cc: "Some # Body" <five@example.com> [part.of.name.too]
+ EOF
+ clean_fake_sendmail &&
+ git send-email -1 --to=recipient@example.com \
+ --smtp-server="$(pwd)/fake.sendmail" &&
+ test_cmp expected-cc commandline1
+'
+
test_expect_success $PREREQ 'setup expect' "
cat >expected-show-all-headers <<\EOF
0001-Second.patch
--
2.10.0.rc0.1.g07c9292
next prev parent reply other threads:[~2016-10-13 5:47 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-10 21:00 Formatting problem send_mail in version 2.10.0 Larry Finger
2016-10-10 21:48 ` Jeff King
2016-10-10 21:57 ` Jeff King
2016-10-10 23:35 ` Larry Finger
2016-10-10 23:43 ` Jeff King
2016-10-11 7:39 ` Matthieu Moy
2016-10-11 15:42 ` Larry Finger
2016-10-11 16:18 ` Matthieu Moy
2016-10-12 4:28 ` Larry Finger
2016-10-12 7:36 ` Matthieu Moy
2016-10-12 15:27 ` Larry Finger
2016-10-12 15:40 ` Matthieu Moy
2016-10-12 15:40 ` Larry Finger
2016-10-12 15:45 ` Matthieu Moy
2016-10-12 15:59 ` Larry Finger
2016-10-12 20:53 ` Junio C Hamano
2016-10-12 23:13 ` Jeff King
2016-10-13 5:37 ` Matthieu Moy
2016-10-13 5:47 ` Matthieu Moy [this message]
2016-10-13 15:33 ` Kevin Daudt
2016-10-13 16:05 ` Matthieu Moy
2016-10-13 5:32 ` Matthieu Moy
2016-10-14 17:04 ` Junio C Hamano
2016-10-11 16:02 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161013054727.13402-1-Matthieu.Moy@imag.fr \
--to=matthieu.moy@imag.fr \
--cc=Larry.Finger@lwfinger.net \
--cc=Mathieu.Lienard--Mayor@ensimag.imag.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=remi.lespinet@ensimag.grenoble-inp.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).