]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-send-email: skip RFC2047 quoting for ASCII subjects
authorKrzysztof Mazur <krzysiek@podlesie.net>
Wed, 24 Oct 2012 08:03:35 +0000 (10:03 +0200)
committerJeff King <peff@peff.net>
Thu, 25 Oct 2012 10:04:38 +0000 (06:04 -0400)
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>
git-send-email.perl
t/t9001-send-email.sh

index adcb4e397b76187a3364456f1511e19a1cb742fb..efeae4c47a2faad2515469f2c34a5b0cb3565d96 100755 (executable)
@@ -1327,7 +1327,8 @@ foreach my $t (@files) {
                $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);
        }
 
index 89fcedaa33728d57efdd494b0bc8f372fc7dc7ae..6c6af7d13f80bdc582e1d45558c24174a5800a38 100755 (executable)
@@ -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