From 4ed1e47b65bfcd2ffd80ac3061fc8a711c4bd92d Mon Sep 17 00:00:00 2001 From: schlatterbeck Date: Wed, 6 Oct 2010 14:13:09 +0000 Subject: [PATCH] - some formatting - fix broken regression-test for message/rfc822 in test_multipart -- the rfc822 message must have its own header -- this is where we have to look for the subject. This means we have to include a newline before the Subject in the test-message, otherwise the Subject line is part of the mime header, not part of the email attachment. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4531 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/mailgw.py | 2 +- test/test_multipart.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/roundup/mailgw.py b/roundup/mailgw.py index 67cf6a3..8346b05 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -1295,7 +1295,7 @@ encrypted.""") # now handle the body - find the message ig = self.instance.config.MAILGW_IGNORE_ALTERNATIVES content, attachments = message.extract_content(ignore_alternatives=ig, - unpack_rfc822 = self.instance.config.MAILGW_UNPACK_RFC822) + unpack_rfc822=self.instance.config.MAILGW_UNPACK_RFC822) if content is None: raise MailUsageError, _(""" Roundup requires the submission to be plain text. The message parser could diff --git a/test/test_multipart.py b/test/test_multipart.py index 5797dd2..0cbc384 100644 --- a/test/test_multipart.py +++ b/test/test_multipart.py @@ -23,13 +23,25 @@ from cStringIO import StringIO from roundup.mailgw import Message class TestMessage(Message): + # A note on message/rfc822: The content of such an attachment is an + # email with at least one header line. RFC2046 tells us: """ A + # media type of "message/rfc822" indicates that the body contains an + # encapsulated message, with the syntax of an RFC 822 message. + # However, unlike top-level RFC 822 messages, the restriction that + # each "message/rfc822" body must include a "From", "Date", and at + # least one destination header is removed and replaced with the + # requirement that at least one of "From", "Subject", or "Date" must + # be present.""" + # This means we have to add a newline after the mime-header before + # the subject, otherwise the subject is part of the mime header not + # part of the email header. table = {'multipart/signed': ' boundary="boundary-%(indent)s";\n', 'multipart/mixed': ' boundary="boundary-%(indent)s";\n', 'multipart/alternative': ' boundary="boundary-%(indent)s";\n', 'text/plain': ' name="foo.txt"\nfoo\n', 'application/pgp-signature': ' name="foo.gpg"\nfoo\n', 'application/pdf': ' name="foo.pdf"\nfoo\n', - 'message/rfc822': 'Subject: foo\n\nfoo\n'} + 'message/rfc822': '\nSubject: foo\n\nfoo\n'} def __init__(self, spec): """Create a basic MIME message according to 'spec'. @@ -215,7 +227,7 @@ multipart/mixed multipart/mixed message/rfc822""", (None, - [('foo', 'message/rfc822', 'foo\n')])) + [('foo.eml', 'message/rfc822', 'Subject: foo\n\nfoo\n')])) def test_suite(): suite = unittest.TestSuite() -- 2.30.2