Merge #15249: Mangle From lines correctly when body contains invalid bytes.

Fix by Colin Su.  Test by me, based on a test written by Petri Lehtinen.
This commit is contained in:
R David Murray 2012-08-24 11:23:50 -04:00
commit ad2a7d528a
4 changed files with 21 additions and 1 deletions

View file

@ -400,6 +400,8 @@ class BytesGenerator(Generator):
if msg._payload is None:
return
if _has_surrogates(msg._payload) and not self.policy.cte_type=='7bit':
if self._mangle_from_:
msg._payload = fcre.sub(">From ", msg._payload)
self.write(msg._payload)
else:
super(BytesGenerator,self)._handle_text(msg)