Title: email.generator.BytesGenerator doesn't mangle "From " lines when non-ASCII bytes are present
Type: Stage: resolved
Components: email Versions: Python 3.2, Python 3.3
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, littleq0903, petri.lehtinen, python-dev, r.david.murray
Priority: normal Keywords: patch

Created on 2012-07-04 10:13 by petri.lehtinen, last changed 2012-08-24 15:33 by r.david.murray. This issue is now closed.

File name Uploaded Description Edit
issue115249_test.patch petri.lehtinen, 2012-07-05 04:18
issue15249.patch littleq0903, 2012-08-23 17:59 Solution review
issue15249_fixed.patch littleq0903, 2012-08-23 18:09 the patch without __init__ changes review
Messages (7)
msg164641 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2012-07-04 10:13
The _handle_text function of BytesGenerator writes the payload straight through if there surrogateescape sequences are present, and skips the "From " mangling.
msg164671 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2012-07-05 04:18
Attached a test case that fails.
msg168951 - (view) Author: Colin Su (littleq0903) * Date: 2012-08-23 17:59
when ByteGenerator entered _has_surrogates() will write the payload directly by not-enter into the super class Generator, which has the replace action.

my solution is just do it also in BytesGenerator.
msg168953 - (view) Author: Colin Su (littleq0903) * Date: 2012-08-23 18:09
Sorry, forgot removing the debugging __init__ method.

the attachment is the patch without the __init__ changes.
msg168961 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2012-08-23 19:31
The patch looks good to me and seems to fix my test case. I find the email code somewhat complicated, so I'll let David decide whether it's the correct fix :)
msg169028 - (view) Author: Roundup Robot (python-dev) Date: 2012-08-24 15:31
New changeset 119c645f310e by R David Murray in branch '3.2':
#15249: Mangle From lines correctly when body contains invalid bytes.

New changeset b6ee4e8c7a77 by R David Murray in branch 'default':
Merge #15249: Mangle From lines correctly when body contains invalid bytes.
msg169029 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-08-24 15:33
Thanks, LittleQ.  And Petri.
Date User Action Args
2012-08-24 15:33:15r.david.murraysetstatus: open -> closed
resolution: fixed
messages: + msg169029

stage: patch review -> resolved
2012-08-24 15:31:40python-devsetnosy: + python-dev
messages: + msg169028
2012-08-23 19:31:59petri.lehtinensetmessages: + msg168961
stage: needs patch -> patch review
2012-08-23 18:09:06littleq0903setfiles: + issue15249_fixed.patch

messages: + msg168953
2012-08-23 17:59:57littleq0903setfiles: + issue15249.patch
nosy: + littleq0903
messages: + msg168951

2012-07-05 04:18:25petri.lehtinensetfiles: + issue115249_test.patch
keywords: + patch
messages: + msg164671
2012-07-04 10:13:06petri.lehtinencreate