Skip to content

Commit 423a9e2

Browse files
committed
Merge branch 'tr/maint-send-email-2047' into maint-1.7.11
"git send-email" did not unquote encoded words that appear on the header correctly, and lost "_" from strings. * tr/maint-send-email-2047: send-email: improve RFC2047 quote parsing
2 parents 5f9d8e3 + b622d4d commit 423a9e2

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

git-send-email.perl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -862,11 +862,13 @@ sub make_message_id {
862862
sub unquote_rfc2047 {
863863
local ($_) = @_;
864864
my $encoding;
865-
if (s/=\?([^?]+)\?q\?(.*)\?=/$2/g) {
865+
s{=\?([^?]+)\?q\?(.*?)\?=}{
866866
$encoding = $1;
867-
s/_/ /g;
868-
s/=([0-9A-F]{2})/chr(hex($1))/eg;
869-
}
867+
my $e = $2;
868+
$e =~ s/_/ /g;
869+
$e =~ s/=([0-9A-F]{2})/chr(hex($1))/eg;
870+
$e;
871+
}eg;
870872
return wantarray ? ($_, $encoding) : $_;
871873
}
872874

t/t9001-send-email.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,19 @@ test_expect_success $PREREQ '--compose adds MIME for utf8 subject' '
841841
grep "^Subject: =?UTF-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
842842
'
843843

844+
test_expect_success $PREREQ 'utf8 author is correctly passed on' '
845+
clean_fake_sendmail &&
846+
test_commit weird_author &&
847+
test_when_finished "git reset --hard HEAD^" &&
848+
git commit --amend --author "Füñný Nâmé <[email protected]>" &&
849+
git format-patch --stdout -1 >funny_name.patch &&
850+
git send-email --from="Example <[email protected]>" \
851+
852+
--smtp-server="$(pwd)/fake.sendmail" \
853+
funny_name.patch &&
854+
grep "^From: Füñný Nâmé <[email protected]>" msgtxt1
855+
'
856+
844857
test_expect_success $PREREQ 'detects ambiguous reference/file conflict' '
845858
echo master > master &&
846859
git add master &&

0 commit comments

Comments
 (0)