send-email: only allow one address per body tag

Adding comments after a tag in the body is a common practise (e.g. in the Linux kernel) and git-send-email has been supporting this for years by removing any trailing cruft after the address. After some recent changes, any trailing comment is now instead appended to the recipient name (with some random white space inserted) resulting in undesirable noise in the headers, for example: CC: "# 3 . 3 . x : 1b9508f : sched : Rate-limit newidle" <stable@vger.kernel.org> Revert to the earlier behaviour of discarding anything after the (first) address in a tag while parsing the body. Note that multiple addresses after are still allowed after a command line switch (and in a CC header field). Also note that --suppress-cc=self was never honoured when using multiple addresses in a tag. Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johan Hovold committed Feb 20, 2017 at 12:44 UTC 9d3343961b845c02f9a3e0e9535492687c404b17
2 files changed +4 -5
git-send-email.perl
+1 -1
@@ -1545,7 +1545,7 @@ foreach my $t (@files) {
1545 # Now parse the message body
1546 while(<$fh>) {
1547 $message .= $_;
1548 - if (/^(Signed-off-by|Cc): (.*)$/i) {
1548 + if (/^(Signed-off-by|Cc): ([^>]*>?)/i) {
1549 chomp;
1550 my ($what, $c) = ($1, $2);
1551 chomp $c;
t/t9001-send-email.sh
+3 -4
@@ -148,7 +148,6 @@ cat >expected-cc <<\EOF
148 !two@example.com!
149 !three@example.com!
150 !four@example.com!
151 -!five@example.com!
151 EOF
152 "
153
@@ -159,9 +158,9 @@ test_expect_success $PREREQ 'cc trailer with various syntax' '
158 Test Cc: trailers.
159
160 Cc: one@example.com
162 - Cc: <two@example.com> # this is part of the name
163 - Cc: <three@example.com>, <four@example.com> # not.five@example.com
164 - Cc: "Some # Body" <five@example.com> [part.of.name.too]
161 + Cc: <two@example.com> # trailing comments are ignored
162 + Cc: <three@example.com>, <not.four@example.com> one address per line
163 + Cc: "Some # Body" <four@example.com> [ <also.a.comment> ]
164 EOF
165 clean_fake_sendmail &&
166 git send-email -1 --to=recipient@example.com \