-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Inconsistent newline handling in email module #40414
Comments
text/* parts of email messages must use \r\n as the Parts which are unencoded (i.e. 7bit character sets) Parts that get encoded using quoted-printable can use However, parts which get encoded using base64 are NOT This means you have to guess whether your text is going I think the fix would be for Charset.encode_body() to |
Email sprint candidate. |
Well, it's two years later, but I did look at this during the sprints at PyCon, though I didn't get as far as posting it then (I only just now rediscovered the patch on my laptop). Python3 no longer has a "binary" flag on base64mime.encode, so here is a proposed patch for Python3. I'm not sure if this should be backported or not, but I'm leaning that way. Theoretically it should be only an improvement, but I can easily imagine unix-only programs unknowingly depending on the previous non-translation of newlines. Still, since email is about intermachine communication and this clearly makes it more RFC compliant, the change is a legitimate bug fix and the chance of breakage is relatively small. Tests are still needed. |
Added some tests against the patch provided by R. David Murray. See attached patch. Tests pass against default. |
I almost applied this patch, but my gut is having second thoughts about it. I don't think this is the correct solution. The correct solution would be to delay the encoding of the body part until the message generation phase, and use the requested linesep at that point. That is, in 3.2 and 3.3 I've changed the paradigm from "always use \n and convert the final string at need" to "specify the linesep when flattening the message". I'm uploading the completed patch here so I don't lose it, but I don't think I'm going to use it in this form. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: