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

bpo-27321 Fix email.generator.py to not replace a non-existent header. #18074

Open
wants to merge 2 commits into
base: master
from

Conversation

@msapiro
Copy link

msapiro commented Jan 20, 2020

This PR replaces #1977. The reason for the replacement is two-fold.

The fix itself is different is that if the CTE header doesn't exist in the original message, it is inserted. This is important because the new CTE could be quoted-printable whereas the original is implicit 8bit.

Also the tests are different. The test_nonascii_as_string_without_cte test in #1977 doesn't actually test the issue in that it passes without the fix. The test_nonascii_as_string_without_content_type_and_cte test is improved here, and even though it doesn't fail without the fix, it is included for completeness.

https://bugs.python.org/issue27321

…tent header.
@msapiro msapiro requested a review from python/email-team as a code owner Jan 20, 2020
@peteroupc

This comment has been minimized.

Copy link

peteroupc commented Jan 20, 2020

Note that the email message example in the issue you linked has no MIME-Version header field. Thus, its interpretation is effectively outside the scope of MIME. As RFC 2045 sec. 4 says:

In the absence of a MIME-Version field, a receiving mail user agent (whether conforming to MIME requirements or not) may optionally choose to interpret the body of the message according to local conventions. Many such conventions are currently in use and it should be noted that in practice non-MIME messages can contain just about anything.

@msapiro

This comment has been minimized.

Copy link
Author

msapiro commented Jan 20, 2020

@peteroupc I'm not sure I understand what you are trying to say in your comment. If you are saying the issue is invalid because the message attached to the bug report had no MIME-Version header, that was the actual message that caused the issue and the issue occurs whether or not the message contains a MIME-Version header.

If you are saying something else, I don't understand what? It is arguably correct that messages which cause this exception to be thrown are not valid messages, but they exist in the wild and should not cause the exception.

In any case, I added a MIME-Version: header to the test message in this PR, but it makes no difference. The test passes with the fix and throws the exception without it.

@peteroupc

This comment has been minimized.

Copy link

peteroupc commented Jan 20, 2020

Since the header field makes no difference, my previous comment is irrelevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.