From 5b56aaa29e9d7c0371b6d47bd8a6b12a0c4292dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20Kleine-K=1B=2CAv=1B=28Bnig?= Date: Mon, 6 Aug 2007 22:34:50 +0200 Subject: [PATCH] send-email: teach sanitize_address to do rfc2047 quoting MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Without this patch I'm not able to properly send emails as I have a non-ascii character in my name. I removed the _rfc822 suffix from the function name as it now does more than rfc822 quoting. I dug through rfc822 to do the double quoting right. Only if that is not possible rfc2047 quoting is applied. Signed-off-by: Uwe Kleine-K,Av(Bnig Cc: Jakub Narebski Signed-off-by: Junio C Hamano --- git-send-email.perl | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/git-send-email.perl b/git-send-email.perl index f43f92f95..39e433b76 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -289,7 +289,7 @@ sub expand_aliases { } @to = expand_aliases(@to); -@to = (map { sanitize_address_rfc822($_) } @to); +@to = (map { sanitize_address($_) } @to); @initial_cc = expand_aliases(@initial_cc); @bcclist = expand_aliases(@bcclist); @@ -459,22 +459,41 @@ sub unquote_rfc2047 { return "$_"; } -# If an address contains a . in the name portion, the name must be quoted. -sub sanitize_address_rfc822 +# use the simplest quoting being able to handle the recipient +sub sanitize_address { my ($recipient) = @_; - my ($recipient_name) = ($recipient =~ /^(.*?)\s+@,;:\\".\000-\037\177]/) { + $recipient_name =~ s/(["\\\r])/\\$1/; + $recipient_name = "\"$recipient_name\""; + } + + return "$recipient_name $recipient_addr"; + } sub send_message { my @recipients = unique_email_list(@to); - @cc = (map { sanitize_address_rfc822($_) } @cc); + @cc = (map { sanitize_address($_) } @cc); my $to = join (",\n\t", @recipients); @recipients = unique_email_list(@recipients,@cc,@bcclist); @recipients = (map { extract_valid_address($_) } @recipients); @@ -489,7 +508,7 @@ sub send_message if ($cc ne '') { $ccline = "\nCc: $cc"; } - $from = sanitize_address_rfc822($from); + $from = sanitize_address($from); make_message_id(); my $header = "From: $from -- 2.30.2