git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] send-email: extend sanitize_address_rfc822 to do rfc2047 quoting
@ 2007-07-10 17:02 Uwe Kleine-König
  2007-07-10 17:02 ` [PATCH] [RFC] send-email: honor --suppress-from --signed-off-cc Uwe Kleine-König
  2007-07-11  8:42 ` [PATCH] send-email: extend sanitize_address_rfc822 to do rfc2047 quoting Sven Verdoolaege
  0 siblings, 2 replies; 7+ messages in thread
From: Uwe Kleine-König @ 2007-07-10 17:02 UTC (permalink / raw)
  To: git; +Cc: Uwe Kleine-König

Without this patch I'm not able to properly send emails as I have a
non-ascii character in my name.

Signed-off-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
---
As I'm not a perl profi, someone wants to check this code.

Actually this series is a test, as it is sended with the patched send-email.

I hope it works :-)

Uwe

 git-send-email.perl |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 89f7c36..8b3d450 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -459,16 +459,30 @@ sub unquote_rfc2047 {
 	return "$_";
 }
 
-# If an address contains a . in the name portion, the name must be quoted.
+# If an address contains a non-ascii char in the name port, quote it according
+# to rfc2047.
+# If an address contains a . in the name portion, the name must be quoted using
+# double quotes.
 sub sanitize_address_rfc822
 {
 	my ($recipient) = @_;
-	my ($recipient_name) = ($recipient =~ /^(.*?)\s+</);
+	my ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)(\s+<.*)/);
+
+	if ($recipient_name && $recipient_name =~ /[^-a-zA-Z0-9!*+\/ ]/ && $recipient_name !~ /=\?utf-8\?q?.*\?=/) {
+		$recipient_name =~ s/([^-a-zA-Z0-9!*+ ])/sprintf("=%02X", ord($1))/eg;
+		$recipient_name =~ s/ /_/;
+		$recipient_name =~ s/(.*)/=\?utf-8\?q\?$1\?=/;
+	}
+
 	if ($recipient_name && $recipient_name =~ /\./ && $recipient_name !~ /^".*"$/) {
-		my ($name, $addr) = ($recipient =~ /^(.*?)(\s+<.*)/);
-		$recipient = "\"$name\"$addr";
+		$recipient_name = "\"$recipient_name\"";
+	}
+
+	if ($recipient_name) {
+		return "$recipient_name$recipient_addr";
+	} else {
+		return "$recipient";
 	}
-	return $recipient;
 }
 
 sub send_message
-- 
1.5.3.rc0.823.gdedbf

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-07-11 12:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-10 17:02 [PATCH] send-email: extend sanitize_address_rfc822 to do rfc2047 quoting Uwe Kleine-König
2007-07-10 17:02 ` [PATCH] [RFC] send-email: honor --suppress-from --signed-off-cc Uwe Kleine-König
2007-07-11  7:55   ` Uwe Kleine-König
2007-07-11  8:42 ` [PATCH] send-email: extend sanitize_address_rfc822 to do rfc2047 quoting Sven Verdoolaege
2007-07-11 11:49   ` Uwe Kleine-König
2007-07-11 12:08     ` Sven Verdoolaege
     [not found]     ` <81b0412b0707110538s7eda05e8g6973e20fc4d91931@mail.gmail.com>
2007-07-11 12:49       ` Sven Verdoolaege

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 NNTP newsgroup(s).