Skip to content

Commit 0b9b17c

Browse files
author
Ralf Schlatterbeck
committed
- 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.
1 parent 7e117f9 commit 0b9b17c

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

roundup/mailgw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ def pgp_role():
12951295
# now handle the body - find the message
12961296
ig = self.instance.config.MAILGW_IGNORE_ALTERNATIVES
12971297
content, attachments = message.extract_content(ignore_alternatives=ig,
1298-
unpack_rfc822 = self.instance.config.MAILGW_UNPACK_RFC822)
1298+
unpack_rfc822=self.instance.config.MAILGW_UNPACK_RFC822)
12991299
if content is None:
13001300
raise MailUsageError, _("""
13011301
Roundup requires the submission to be plain text. The message parser could

test/test_multipart.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,25 @@
2323
from roundup.mailgw import Message
2424

2525
class TestMessage(Message):
26+
# A note on message/rfc822: The content of such an attachment is an
27+
# email with at least one header line. RFC2046 tells us: """ A
28+
# media type of "message/rfc822" indicates that the body contains an
29+
# encapsulated message, with the syntax of an RFC 822 message.
30+
# However, unlike top-level RFC 822 messages, the restriction that
31+
# each "message/rfc822" body must include a "From", "Date", and at
32+
# least one destination header is removed and replaced with the
33+
# requirement that at least one of "From", "Subject", or "Date" must
34+
# be present."""
35+
# This means we have to add a newline after the mime-header before
36+
# the subject, otherwise the subject is part of the mime header not
37+
# part of the email header.
2638
table = {'multipart/signed': ' boundary="boundary-%(indent)s";\n',
2739
'multipart/mixed': ' boundary="boundary-%(indent)s";\n',
2840
'multipart/alternative': ' boundary="boundary-%(indent)s";\n',
2941
'text/plain': ' name="foo.txt"\nfoo\n',
3042
'application/pgp-signature': ' name="foo.gpg"\nfoo\n',
3143
'application/pdf': ' name="foo.pdf"\nfoo\n',
32-
'message/rfc822': 'Subject: foo\n\nfoo\n'}
44+
'message/rfc822': '\nSubject: foo\n\nfoo\n'}
3345

3446
def __init__(self, spec):
3547
"""Create a basic MIME message according to 'spec'.
@@ -215,7 +227,7 @@ def testMessageRfc822(self):
215227
multipart/mixed
216228
message/rfc822""",
217229
(None,
218-
[('foo', 'message/rfc822', 'foo\n')]))
230+
[('foo.eml', 'message/rfc822', 'Subject: foo\n\nfoo\n')]))
219231

220232
def test_suite():
221233
suite = unittest.TestSuite()

0 commit comments

Comments
 (0)