send-email: work around double encoding of in-body From field.
git-send-email sends out the message taken from format-patch output without quoting nor encoding. When copying the From: line to form in-body From: field, it should not copy it verbatim, because the From: for the header is quoted according to RFC 2047 when not ASCII. The original came from Jürgen Rühle, but I moved the string munging into a separate function so that later other people can tweak it more easily. Bugs introduced during the translation are mine. Signed-off-by: Junio C Hamano <junkio@cox.net>
Jürgen Rühle committed
Jan 10, 2007 at 13:36 UTC
374c59056a0719fe1244280cdb6fdce48672f441
1 file changed
+10
git-send-email.perl
+10
@@ -402,6 +402,15 @@ sub make_message_id
402
$cc = "";
403
$time = time - scalar $#files;
404
405
+sub unquote_rfc2047 {
406
+ local ($_) = @_;
407
+ if (s/=\?utf-8\?q\?(.*)\?=/$1/g) {
408
+ s/_/ /g;
409
+ s/=([0-9A-F]{2})/chr(hex($1))/eg;
410
+ }
411
+ return "$_ - unquoted";
412
+}
413
+
414
sub send_message
415
{
416
my @recipients = unique_email_list(@to);
@@ -555,6 +564,7 @@ foreach my $t (@files) {
564
}
565
close F;
566
if (defined $author_not_sender) {
567
+ $author_not_sender = unquote_rfc2047($author_not_sender);
568
$message = "From: $author_not_sender\n\n$message";
569
}
570