summaryrefslogtreecommitdiffstats
path: root/Lib/email/test
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-12-13 23:51:19 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-12-13 23:51:19 (GMT)
commit7ec754b7da863c5b0c5ca212da8a2585db989bf8 (patch)
treeb388a68e00b9ee639129033bc3983fbe94cb2a64 /Lib/email/test
parent796343b1988e3e47c9b400053f844c2bb0352d9a (diff)
downloadcpython-7ec754b7da863c5b0c5ca212da8a2585db989bf8.zip
cpython-7ec754b7da863c5b0c5ca212da8a2585db989bf8.tar.gz
cpython-7ec754b7da863c5b0c5ca212da8a2585db989bf8.tar.bz2
#1078919: make add_header automatically do RFC2231 encoding when needed.
Also document the use of three-tuples if control of the charset and language is desired.
Diffstat (limited to 'Lib/email/test')
-rw-r--r--Lib/email/test/test_email.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index 7993486..78fb961 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -510,6 +510,29 @@ class TestMessageAPI(TestEmailBase):
self.assertEqual(msg.get_payload(decode=True),
bytes(x, 'raw-unicode-escape'))
+ # Issue 1078919
+ def test_ascii_add_header(self):
+ msg = Message()
+ msg.add_header('Content-Disposition', 'attachment',
+ filename='bud.gif')
+ self.assertEqual('attachment; filename="bud.gif"',
+ msg['Content-Disposition'])
+
+ def test_noascii_add_header(self):
+ msg = Message()
+ msg.add_header('Content-Disposition', 'attachment',
+ filename="Fußballer.ppt")
+ self.assertEqual(
+ 'attachment; filename*="utf-8\'\'Fu%C3%9Fballer.ppt"',
+ msg['Content-Disposition'])
+
+ def test_nonascii_add_header_via_triple(self):
+ msg = Message()
+ msg.add_header('Content-Disposition', 'attachment',
+ filename=('iso-8859-1', '', 'Fußballer.ppt'))
+ self.assertEqual(
+ 'attachment; filename*="iso-8859-1\'\'Fu%DFballer.ppt"',
+ msg['Content-Disposition'])
# Test the email.encoders module