Skip to content

Commit 5637d85

Browse files
Krzysztof Mazurpeff
authored andcommitted
git-send-email: skip RFC2047 quoting for ASCII subjects
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 <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent 4a47a4d commit 5637d85

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

git-send-email.perl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,8 @@ sub send_message {
13271327
$body_encoding = $auto_8bit_encoding;
13281328
}
13291329

1330-
if ($broken_encoding{$t} && !is_rfc2047_quoted($subject)) {
1330+
if ($broken_encoding{$t} && !is_rfc2047_quoted($subject) &&
1331+
($subject =~ /[^[:ascii:]]/)) {
13311332
$subject = quote_rfc2047($subject, $auto_8bit_encoding);
13321333
}
13331334

t/t9001-send-email.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,23 @@ Dieser deutsche Text enthält einen Umlaut!
11421142
EOF
11431143
'
11441144

1145+
test_expect_success $PREREQ 'setup expect' '
1146+
cat >expected <<EOF
1147+
Subject: subject goes here
1148+
EOF
1149+
'
1150+
1151+
test_expect_success $PREREQ 'ASCII subject is not RFC2047 quoted' '
1152+
clean_fake_sendmail &&
1153+
echo bogus |
1154+
1155+
--smtp-server="$(pwd)/fake.sendmail" \
1156+
--8bit-encoding=UTF-8 \
1157+
email-using-8bit >stdout &&
1158+
grep "Subject" msgtxt1 >actual &&
1159+
test_cmp expected actual
1160+
'
1161+
11451162
test_expect_success $PREREQ 'setup expect' '
11461163
cat >content-type-decl <<EOF
11471164
MIME-Version: 1.0

0 commit comments

Comments
 (0)