git-send-email: remove garbage after email address

In some cases it is useful to add additional information after the email address on the Cc: footer in a commit log, for instance: "Cc: Stable kernel <stable@vger.kernel.org> #v3.4 v3.5 v3.6" However, git-send-email refuses to pick up such an invalid address when the Email::Valid perl module is available, or just uses the whole line as the email address. In sanitize_address(), remove everything after the email address, so that the result is a valid email address that makes Email::Valid happy. Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net> Tested-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Krzysztof Mazur committed Nov 22, 2012 at 19:12 UTC 831a488b76e0fcad68c6d1c7aaf9f086199e1738
1 file changed +4
git-send-email.perl
+4
@@ -924,6 +924,10 @@ sub quote_subject {
924 # use the simplest quoting being able to handle the recipient
925 sub sanitize_address {
926 my ($recipient) = @_;
927 +
928 + # remove garbage after email address
929 + $recipient =~ s/(.*>).*$/$1/;
930 +
931 my ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)\s*(<.*)/);
932
933 if (not $recipient_name) {