diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2018-07-09 01:17:10 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-07-09 20:55:12 +0300 |
commit | 7a36987ffffa59052723ed7299c1de25bc18048a (patch) | |
tree | 0973270e42b7ede4c0bec91fe383b9a09109bb95 /git-send-email.perl | |
parent | 53f9a3e157dbbc901a02ac2c73346d375e24978c (diff) |
send-email: add an auto option for transfer encoding
For most patches, using a transfer encoding of 8bit provides good
compatibility with most servers and makes it as easy as possible to view
patches. However, there are some patches for which 8bit is not a valid
encoding: RFC 5322 specifies that a message must not have lines
exceeding 998 octets.
Add a transfer encoding value, auto, which indicates that a patch should
use 8bit where allowed and quoted-printable otherwise. Choose
quoted-printable instead of base64, since base64-encoded plain text is
treated as suspicious by some spam filters.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-x | git-send-email.perl | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/git-send-email.perl b/git-send-email.perl index 8ec70e58ed..1736a09d21 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -1739,9 +1739,8 @@ sub process_file { } if (defined $target_xfer_encoding) { $xfer_encoding = '8bit' if not defined $xfer_encoding; - $message = apply_transfer_encoding( + ($message, $xfer_encoding) = apply_transfer_encoding( $message, $xfer_encoding, $target_xfer_encoding); - $xfer_encoding = $target_xfer_encoding; } if (defined $xfer_encoding) { push @xh, "Content-Transfer-Encoding: $xfer_encoding"; @@ -1852,13 +1851,16 @@ sub apply_transfer_encoding { $message = MIME::Base64::decode($message) if ($from eq 'base64'); + $to = ($message =~ /.{999,}/) ? 'quoted-printable' : '8bit' + if $to eq 'auto'; + die __("cannot send message as 7bit") if ($to eq '7bit' and $message =~ /[^[:ascii:]]/); - return $message + return ($message, $to) if ($to eq '7bit' or $to eq '8bit'); - return MIME::QuotedPrint::encode($message, "\n", 0) + return (MIME::QuotedPrint::encode($message, "\n", 0), $to) if ($to eq 'quoted-printable'); - return MIME::Base64::encode($message, "\n") + return (MIME::Base64::encode($message, "\n"), $to) if ($to eq 'base64'); die __("invalid transfer encoding"); } |