diff options
author | Barry Warsaw <barry@python.org> | 2002-04-10 21:01:31 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2002-04-10 21:01:31 (GMT) |
commit | 409a4c08b545aa064cf8fe3b8de51404756a301e (patch) | |
tree | 06cf8fe44e1fe28fbc0147635ec41961f2df6515 /Lib/email/Encoders.py | |
parent | 68e69338ae19c37bd3e69cb76e107bfa76231e06 (diff) | |
download | cpython-409a4c08b545aa064cf8fe3b8de51404756a301e.zip cpython-409a4c08b545aa064cf8fe3b8de51404756a301e.tar.gz cpython-409a4c08b545aa064cf8fe3b8de51404756a301e.tar.bz2 |
Sync'ing with standalone email package 2.0.1. This adds support for
non-us-ascii character sets in headers and bodies. Some API changes
(with DeprecationWarnings for the old APIs). Better RFC-compliant
implementations of base64 and quoted-printable.
Updated test cases. Documentation updates to follow (after I finish
writing them ;).
Diffstat (limited to 'Lib/email/Encoders.py')
-rw-r--r-- | Lib/email/Encoders.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/email/Encoders.py b/Lib/email/Encoders.py index d9cd42d..f09affa 100644 --- a/Lib/email/Encoders.py +++ b/Lib/email/Encoders.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001 Python Software Foundation +# Copyright (C) 2001,2002 Python Software Foundation # Author: barry@zope.com (Barry Warsaw) """Module containing encoding functions for Image.Image and Text.Text. @@ -11,7 +11,9 @@ from quopri import encodestring as _encodestring # Helpers def _qencode(s): - return _encodestring(s, quotetabs=1) + enc = _encodestring(s, quotetabs=1) + # Must encode spaces, which quopri.encodestring() doesn't do + return enc.replace(' ', '=20') def _bencode(s): @@ -54,6 +56,10 @@ def encode_quopri(msg): def encode_7or8bit(msg): """Set the Content-Transfer-Encoding: header to 7bit or 8bit.""" orig = msg.get_payload() + if orig is None: + # There's no payload. For backwards compatibility we use 7bit + msg['Content-Transfer-Encoding'] = '7bit' + return # We play a trick to make this go fast. If encoding to ASCII succeeds, we # know the data must be 7bit, otherwise treat it as 8bit. try: |