summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2003-08-19 03:54:24 (GMT)
committerBarry Warsaw <barry@python.org>2003-08-19 03:54:24 (GMT)
commit622d60b5a2ad1ffb4e35b32ab1934af066f2ccd5 (patch)
treeb0c6c9efa52678b3366af1f41055de8e847fbb00 /Lib/email
parent6208369ff3ec94604dd19500c6d14427301751ef (diff)
downloadcpython-622d60b5a2ad1ffb4e35b32ab1934af066f2ccd5.zip
cpython-622d60b5a2ad1ffb4e35b32ab1934af066f2ccd5.tar.gz
cpython-622d60b5a2ad1ffb4e35b32ab1934af066f2ccd5.tar.bz2
test_rfc2231_no_language_or_charset_in_filename(),
test_rfc2231_no_language_or_charset_in_boundary(), test_rfc2231_no_language_or_charset_in_charset(): New tests for proper decoding of some RFC 2231 headers. Backport candidate (as was the Utils.py 1.25 change) to both Python 2.3.1 and 2.2.4 -- will do momentarily.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/test/test_email.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index 7e630bf..a14199d 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -2659,6 +2659,43 @@ Content-Type: text/html; NAME*0=file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOC
self.assertEqual(msg.get_param('NAME'),
(None, None, 'file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm'))
+ def test_rfc2231_no_language_or_charset_in_filename(self):
+ m = '''\
+Content-Disposition: inline;
+\tfilename*0="This%20is%20even%20more%20";
+\tfilename*1="%2A%2A%2Afun%2A%2A%2A%20";
+\tfilename*2="is it not.pdf"
+
+'''
+ msg = email.message_from_string(m)
+ self.assertEqual(msg.get_filename(),
+ 'This is even more ***fun*** is it not.pdf')
+
+ def test_rfc2231_no_language_or_charset_in_boundary(self):
+ m = '''\
+Content-Type: multipart/alternative;
+\tboundary*0="This%20is%20even%20more%20";
+\tboundary*1="%2A%2A%2Afun%2A%2A%2A%20";
+\tboundary*2="is it not.pdf"
+
+'''
+ msg = email.message_from_string(m)
+ self.assertEqual(msg.get_boundary(),
+ 'This is even more ***fun*** is it not.pdf')
+
+ def test_rfc2231_no_language_or_charset_in_charset(self):
+ # This is a nonsensical charset value, but tests the code anyway
+ m = '''\
+Content-Type: text/plain;
+\tcharset*0="This%20is%20even%20more%20";
+\tcharset*1="%2A%2A%2Afun%2A%2A%2A%20";
+\tcharset*2="is it not.pdf"
+
+'''
+ msg = email.message_from_string(m)
+ self.assertEqual(msg.get_content_charset(),
+ 'this is even more ***fun*** is it not.pdf')
+
def _testclasses():