Changeset 391 for python/trunk/Lib/email/generator.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/email/generator.py
r2 r391 1 # Copyright (C) 2001-2006 Python Software Foundation 2 # Author: Barry Warsaw 1 # Copyright (C) 2001-2010 Python Software Foundation 3 2 # Contact: email-sig@python.org 4 3 … … 158 157 print >> self._fp, v 159 158 else: 160 # Header's got lots of smarts, so use it. 159 # Header's got lots of smarts, so use it. Note that this is 160 # fundamentally broken though because we lose idempotency when 161 # the header string is continued with tabs. It will now be 162 # continued with spaces. This was reversedly broken before we 163 # fixed bug 1974. Either way, we lose. 161 164 print >> self._fp, Header( 162 v, maxlinelen=self._maxheaderlen, 163 header_name=h, continuation_ws='\t').encode() 165 v, maxlinelen=self._maxheaderlen, header_name=h).encode() 164 166 # A blank line always separates headers from body 165 167 print >> self._fp … … 202 204 g.flatten(part, unixfrom=False) 203 205 msgtexts.append(s.getvalue()) 204 # Now make sure the boundary we've selected doesn't appear in any of205 # the message texts.206 alltext = NL.join(msgtexts)207 206 # BAW: What about boundaries that are wrapped in double-quotes? 208 boundary = msg.get_boundary(failobj=_make_boundary(alltext)) 209 # If we had to calculate a new boundary because the body text 210 # contained that string, set the new boundary. We don't do it 211 # unconditionally because, while set_boundary() preserves order, it 212 # doesn't preserve newlines/continuations in headers. This is no big 213 # deal in practice, but turns out to be inconvenient for the unittest 214 # suite. 215 if msg.get_boundary() != boundary: 207 boundary = msg.get_boundary() 208 if not boundary: 209 # Create a boundary that doesn't appear in any of the 210 # message texts. 211 alltext = NL.join(msgtexts) 212 boundary = _make_boundary(alltext) 216 213 msg.set_boundary(boundary) 217 214 # If there's a preamble, write it out, with a trailing CRLF 218 215 if msg.preamble is not None: 219 print >> self._fp, msg.preamble 216 if self._mangle_from_: 217 preamble = fcre.sub('>From ', msg.preamble) 218 else: 219 preamble = msg.preamble 220 print >> self._fp, preamble 220 221 # dash-boundary transport-padding CRLF 221 222 print >> self._fp, '--' + boundary … … 235 236 if msg.epilogue is not None: 236 237 print >> self._fp 237 self._fp.write(msg.epilogue) 238 if self._mangle_from_: 239 epilogue = fcre.sub('>From ', msg.epilogue) 240 else: 241 epilogue = msg.epilogue 242 self._fp.write(epilogue) 238 243 239 244 def _handle_multipart_signed(self, msg): … … 293 298 294 299 class DecodedGenerator(Generator): 295 """Generat ora text representation of a message.300 """Generates a text representation of a message. 296 301 297 302 Like the Generator base class, except that non-text parts are substituted
Note:
See TracChangeset
for help on using the changeset viewer.