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 <krzysiek@podlesie.net> Signed-off-by: Jeff King <peff@peff.net>
Krzysztof Mazur committed
Oct 24, 2012 at 10:03 UTC
5637d8573206e8c3d99abacb6b6ca3cf11816202
2 files changed
+19
-1
git-send-email.perl
+2
-1
@@ -1327,7 +1327,8 @@ foreach my $t (@files) {
1327
$body_encoding = $auto_8bit_encoding;
1328
}
1329
1330
- if ($broken_encoding{$t} && !is_rfc2047_quoted($subject)) {
1330
+ if ($broken_encoding{$t} && !is_rfc2047_quoted($subject) &&
1331
+ ($subject =~ /[^[:ascii:]]/)) {
1332
$subject = quote_rfc2047($subject, $auto_8bit_encoding);
1333
}
1334
t/t9001-send-email.sh
+17
@@ -1142,6 +1142,23 @@ Dieser deutsche Text enthält einen Umlaut!
1142
EOF
1143
'
1144
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
+ git send-email --from=author@example.com --to=nobody@example.com \
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
+
1162
test_expect_success $PREREQ 'setup expect' '
1163
cat >content-type-decl <<EOF
1164
MIME-Version: 1.0