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

BytesGenerator does not handle 'binary' CTE correctly #63086

Open
bitdancer opened this issue Aug 30, 2013 · 7 comments
Open

BytesGenerator does not handle 'binary' CTE correctly #63086

bitdancer opened this issue Aug 30, 2013 · 7 comments
Labels
stdlib Python modules in the Lib dir topic-email type-feature A feature request or enhancement

Comments

@bitdancer
Copy link
Member

BPO 18886
Nosy @warsaw, @bitdancer, @nathanielmanistaatgoogle

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:

assignee = None
closed_at = None
created_at = <Date 2013-08-30.20:37:30.754>
labels = ['type-feature', 'expert-email']
title = "BytesGenerator does not handle 'binary' CTE correctly"
updated_at = <Date 2015-10-15.01:01:03.106>
user = 'https://github.com/bitdancer'

bugs.python.org fields:

activity = <Date 2015-10-15.01:01:03.106>
actor = 'r.david.murray'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['email']
creation = <Date 2013-08-30.20:37:30.754>
creator = 'r.david.murray'
dependencies = []
files = []
hgrepos = []
issue_num = 18886
keywords = []
message_count = 7.0
messages = ['196572', '212697', '212717', '212724', '253021', '253022', '253024']
nosy_count = 4.0
nosy_names = ['barry', 'r.david.murray', 'suryak', 'Nathaniel Manista']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue18886'
versions = ['Python 3.6']

@bitdancer
Copy link
Member Author

ByteGenerator will assume that it can change any linesep characters to the linesep being used for the general message serialization, even if the content transfer encoding is 'binary'. This is incorrect, as existing \r and \n characters in binary parts must be retained exactly as is.

@bitdancer bitdancer added type-bug An unexpected behavior, bug, or error topic-email labels Aug 30, 2013
@suryak
Copy link
Mannequin

suryak mannequin commented Mar 4, 2014

I have a fix for this. But before putting it forward, can you please tell me about the below

  1. email.header.Header.encode() --method
    How different is it from str.encode()? Does [1] method also performs what str.encode() does internally?

@suryak
Copy link
Mannequin

suryak mannequin commented Mar 4, 2014

Forget about my previous comment.
David Murray:

One possible way to fix this issue is to ignore email.header.Header.encode() on Message values in email._policybase_Compat32._fold() if they come from BytesGenerator and not Generator. We can do this by encoding the value to bytes in email.generator.BytesGenerator._write_headers()

Do you think its a fix? Or even values from ByteGenerators should be formatted using Header.encode()? In that case, I'd look into how it can be done.

@bitdancer
Copy link
Member Author

cte binary has nothing to do with headers (other than appearing as the value of the content-transfer-encoding header). It is about how the body of the email is handled. ByteGenerator needs to be modified to not do anything with a payload whose cte is binary other than write it to the output stream as bytes. This of course means it is ignoring max_line_length...so it is an interesting question whether or not CTE binary should be supported if max_line_length is anything other than 0/None.

@nathanielmanistaatgoogle
Copy link
Mannequin

This is status:open but versions:3.3,3.4. Should 3.5 and 3.6 also be listed as being affected by this issue?

@nathanielmanistaatgoogle
Copy link
Mannequin

Also what's this bug's relationship to 19003?

@bitdancer
Copy link
Member Author

Just 3.6 at this point, since really support for CTE binary is a new feature (there may even be a separate issue saying that, in which case this one should be closed as a duplicate). We don't auto-update the issue versions when a new release comes out.

bpo-19003 is a bug involving the handling of bytes payloads (but not binary CTE) and so is different.

@bitdancer bitdancer added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Oct 15, 2015
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@iritkatriel iritkatriel added the stdlib Python modules in the Lib dir label Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-email type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants