-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force quopri to use CRLF for soft line breaks #199
base: master
Are you sure you want to change the base?
Conversation
Can one of the admins verify this patch? |
Working on fixing tests... |
77d3718
to
5b3f37b
Compare
quopri tries to automatically detect which type of line ending it should use for soft line breaks which can lead it to making the wrong decision where it tries to use =LF rather than =CRLF. This diff fixes this by prepending a CRLF when encoding a part's body to force quopri to use CRLF and then removes that prefix afterwards.
5b3f37b
to
d93f6bc
Compare
@@ -631,7 +631,9 @@ def _encode_charset(preferred_charset, text): | |||
def _encode_transfer_encoding(encoding, body): | |||
if six.PY3: | |||
if encoding == 'quoted-printable': | |||
body = b''.join([b'\r\n', body]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather make it as simple as body = b'\r\n' + body
@@ -647,7 +649,9 @@ def _encode_transfer_encoding(encoding, body): | |||
return body | |||
|
|||
if encoding == 'quoted-printable': | |||
return quopri.encodestring(body, quotetabs=False) | |||
body = '\r\n{}'.format(body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here body = '\r\n' + body
quopri tries to automatically detect which type of line ending it should
use for soft line breaks which can lead it to making the wrong decision
where it tries to use =LF rather than =CRLF. This diff fixes this by
prepending a CRLF when encoding a part's body to force quopri to use
CRLF and then removes that prefix afterwards.