summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2004-05-13 20:15:20 (GMT)
committerBarry Warsaw <barry@python.org>2004-05-13 20:15:20 (GMT)
commit58eb0fcb8f33e8bfd1f850f42c9efb27e1b48417 (patch)
tree318b4802dd32d943883659a085724dc7e59908a2 /Lib/email
parentd49f1d6c5aa30ce441a976eee7e7dca0a06f1e19 (diff)
downloadcpython-58eb0fcb8f33e8bfd1f850f42c9efb27e1b48417.zip
cpython-58eb0fcb8f33e8bfd1f850f42c9efb27e1b48417.tar.gz
cpython-58eb0fcb8f33e8bfd1f850f42c9efb27e1b48417.tar.bz2
test_nested_inner_contains_outer_boundary(), test_nested_with_same_boundary():
Two evil samples from Anthony's MIME torture tests.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/test/test_email.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index bd27960..59163f4 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -1325,6 +1325,42 @@ hello world
msg = self._msgobj('msg_37.txt')
self.assertEqual(len(msg.get_payload()), 3)
+ def test_nested_inner_contains_outer_boundary(self):
+ eq = self.ndiffAssertEqual
+ # msg_38.txt has an inner part that contains outer boundaries. My
+ # interpretation of RFC 2046 (based on sections 5.1 and 5.1.2) say
+ # these are illegal and should be interpreted as unterminated inner
+ # parts.
+ msg = self._msgobj('msg_38.txt')
+ sfp = StringIO()
+ Iterators._structure(msg, sfp)
+ eq(sfp.getvalue(), """\
+multipart/mixed
+ multipart/mixed
+ multipart/alternative
+ text/plain
+ text/plain
+ text/plain
+ text/plain
+""")
+
+ def test_nested_with_same_boundary(self):
+ eq = self.ndiffAssertEqual
+ # msg 39.txt is similarly evil in that it's got inner parts that use
+ # the same boundary as outer parts. Again, I believe the way this is
+ # parsed is closest to the spirit of RFC 2046
+ msg = self._msgobj('msg_39.txt')
+ sfp = StringIO()
+ Iterators._structure(msg, sfp)
+ eq(sfp.getvalue(), """\
+multipart/mixed
+ multipart/mixed
+ multipart/alternative
+ application/octet-stream
+ application/octet-stream
+ text/plain
+""")
+
# Test some badly formatted messages