path: root/git-send-email.perl
diff options
authorbrian m. carlson <>2019-04-13 22:45:51 (GMT)
committerJunio C Hamano <>2019-04-14 02:47:03 (GMT)
commit74d76a17013411d72ebda7c230b9898f3adb1fcc (patch)
treef4d337dc9f436de9fb381f002c103181e65fd65a /git-send-email.perl
parentaeb582a98374c094361cba1bd756dc6307432c42 (diff)
send-email: default to quoted-printable when CR is present
In 7a36987fff ("send-email: add an auto option for transfer encoding", 2018-07-08), git send-email learned how to automatically determine the transfer encoding for a patch. However, the only criterion considered was the length of the lines. Another case we need to consider is that of carriage returns. Because emails have CRLF endings when canonicalized, we don't want to write raw carriage returns into a patch, lest they be stripped off as an artifact of the transport. Ensure that we choose quoted-printable encoding if the patch we're sending contains carriage returns. Note that we are guaranteed to always correctly encode carriage returns when writing quoted-printable since we explicitly specify the line ending as "\n", forcing MIME::QuotedPrint to encode our carriage return as "=0D". Signed-off-by: brian m. carlson <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'git-send-email.perl')
1 files changed, 1 insertions, 1 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 8eb63b5..3f66e1c 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1866,7 +1866,7 @@ sub apply_transfer_encoding {
$message = MIME::Base64::decode($message)
if ($from eq 'base64');
- $to = ($message =~ /.{999,}/) ? 'quoted-printable' : '8bit'
+ $to = ($message =~ /(?:.{999,}|\r)/) ? 'quoted-printable' : '8bit'
if $to eq 'auto';
die __("cannot send message as 7bit")