Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mhahnenberg
Copy link
Contributor

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.

@mailgun-ci
Copy link

Can one of the admins verify this patch?

@mhahnenberg
Copy link
Contributor Author

Working on fixing tests...

@mhahnenberg mhahnenberg force-pushed the fix-long-quoted-printable-crlf branch 4 times, most recently from 77d3718 to 5b3f37b Compare May 21, 2018 21:40
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.
@mhahnenberg mhahnenberg force-pushed the fix-long-quoted-printable-crlf branch from 5b3f37b to d93f6bc Compare May 21, 2018 21:44
@@ -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])
Copy link
Member

@horkhe horkhe Jun 1, 2018

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)
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants