Conversation
…opri() Both encoders added a Content-Transfer-Encoding header without removing an existing one, so re-encoding a message that already had one left two such headers. Delete the old header first. encode_7or8bit() is left alone because it does not change the payload.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
encode_base64()andencode_quopri()add a Content-Transfer-Encoding header without removing an existing one. Re-encoding a message that already has one, such as a utf-8MIMEText, leaves two headers, andget_payload(decode=True)then decodes the body with the old one:The double-encoded payload was fixed in 2013 by gh-62524 (bpo-18324), which made the encoders decode the payload first. In 2021 the reporter confirmed the duplicate header was still there. R. David Murray had said the encoders' behavior on an already encoded message could be fixed, "since it is unlikely that anyone would be depending on such behavior". Both functions rewrite the payload, so the old header can be deleted before the new one is set. With
email.policy.default, which allows only one such header, they used to raiseValueErrorhere and now work.encode_7or8bit()is left alone, although I listed it on the issue. It doesn't touch the payload, so on a base64 or quoted-printable body the old header is the one that still describes it. Replacing it would mislabel the body.#43702