Skip to content

Commit

Permalink
git-send-email: skip RFC2047 quoting for ASCII subjects
Browse files Browse the repository at this point in the history
The git-send-email always use RFC2047 subject quoting for
files with "broken" encoding - non-ASCII files without
Content-Transfer-Encoding, even for ASCII subjects. This is
harmless but unnecessarily ugly for people reading the raw
headers. This patch skips rfc2047 quoting when the subject
does not need it.

Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net>
Signed-off-by: Jeff King <peff@peff.net>
  • Loading branch information
Krzysztof Mazur authored and Jeff King committed Oct 25, 2012
1 parent 4a47a4d commit 5637d85
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,8 @@ sub send_message {
$body_encoding = $auto_8bit_encoding;
}

if ($broken_encoding{$t} && !is_rfc2047_quoted($subject)) {
if ($broken_encoding{$t} && !is_rfc2047_quoted($subject) &&
($subject =~ /[^[:ascii:]]/)) {
$subject = quote_rfc2047($subject, $auto_8bit_encoding);
}

Expand Down
17 changes: 17 additions & 0 deletions t/t9001-send-email.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,23 @@ Dieser deutsche Text enthält einen Umlaut!
EOF
'

test_expect_success $PREREQ 'setup expect' '
cat >expected <<EOF
Subject: subject goes here
EOF
'

test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' '
clean_fake_sendmail &&
echo bogus |
git send-email --from=author@example.com --to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \
--8bit-encoding=UTF-8 \
email-using-8bit >stdout &&
grep "Subject" msgtxt1 >actual &&
test_cmp expected actual
'

test_expect_success $PREREQ 'setup expect' '
cat >content-type-decl <<EOF
MIME-Version: 1.0
Expand Down

0 comments on commit 5637d85

Please sign in to comment.