send-email: only allow one address per body tag
authorJohan Hovold <johan@kernel.org>
Mon, 20 Feb 2017 11:44:06 +0000 (12:44 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Feb 2017 18:02:55 +0000 (10:02 -0800)
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>
git-send-email.perl
t/t9001-send-email.sh
index da81be40cb7f9af1a960be2c22f8e75c9d16822e..2bc656ee7a850e9f47de7a8af2d3ae980755c53b 100755 (executable)
@@ -1545,7 +1545,7 @@ sub send_message {
        # Now parse the message body
        while(<$fh>) {
                $message .=  $_;
-               if (/^(Signed-off-by|Cc): (.*)$/i) {
+               if (/^(Signed-off-by|Cc): ([^>]*>?)/i) {
                        chomp;
                        my ($what, $c) = ($1, $2);
                        chomp $c;
index 3dc4a3454d223d37e85de6fa4ae8656046370e99..411df042bf06580fcf19d8e543ef15ec8debe2b6 100755 (executable)
@@ -148,7 +148,6 @@ cat >expected-cc <<\EOF
 !two@example.com!
 !three@example.com!
 !four@example.com!
-!five@example.com!
 EOF
 "
 
@@ -159,9 +158,9 @@ test_expect_success $PREREQ 'cc trailer with various syntax' '
        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]
+       Cc: <two@example.com> # trailing comments are ignored
+       Cc: <three@example.com>, <not.four@example.com> one address per line
+       Cc: "Some # Body" <four@example.com> [ <also.a.comment> ]
        EOF
        clean_fake_sendmail &&
        git send-email -1 --to=recipient@example.com \