Skip to content

Commit 6c5c493

Browse files
committed
Add failing transcoding test
An attachment with Content-Type application/octet is transcoded to utf-8, originally the attachment is in latin1 (although that doen't matter, no charset can be asumed for a binary-only attachment).
1 parent 7b426cd commit 6c5c493

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/test_mailgw.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,35 @@ def testNewIssueNoAuthorEmail(self):
668668
_______________________________________________________________________
669669
''')
670670

671+
octetstream_msg = '''From: mary <[email protected]>
672+
673+
Message-Id: <followup_dummy_id>
674+
In-Reply-To: <dummy_test_message_id>
675+
Subject: [issue1] Testing...
676+
Content-Type: multipart/mixed; boundary="uh56ypi7view24rr"
677+
Content-Disposition: inline
678+
679+
--uh56ypi7view24rr
680+
Content-Type: text/plain; charset=us-ascii
681+
Content-Disposition: inline
682+
683+
Attach a file with non-ascii characters in it (encoded latin-1 should
684+
make it as-is through roundup due to Content-Type
685+
application/octet-stream)
686+
--
687+
Ralf Schlatterbeck email: [email protected]
688+
689+
--uh56ypi7view24rr
690+
Content-Type: application/octet-stream
691+
Content-Disposition: attachment; filename=testfile
692+
Content-Transfer-Encoding: quoted-printable
693+
694+
This is a file containing text
695+
in latin-1 format =E4=F6=FC=C4=D6=DC=DF
696+
697+
--uh56ypi7view24rr--
698+
'''
699+
671700
multipart_msg = '''From: mary <[email protected]>
672701
673702
Message-Id: <followup_dummy_id>
@@ -803,6 +832,22 @@ def testNewIssueNoAuthorEmail(self):
803832
--001485f339f8f361fb049188dbba--
804833
'''
805834

835+
def testOctetStreamTranscoding(self):
836+
self.doNewIssue()
837+
self._handle_mail(self.octetstream_msg)
838+
messages = self.db.issue.get('1', 'messages')
839+
messages.sort()
840+
msg = self.db.msg.getnode (messages[-1])
841+
assert(len(msg.files) == 1)
842+
names = {0 : 'testfile'}
843+
content = ['''This is a file containing text
844+
in latin-1 format \xE4\xF6\xFC\xC4\xD6\xDC\xDF
845+
''']
846+
for n, id in enumerate (msg.files):
847+
f = self.db.file.getnode (id)
848+
self.assertEqual(f.name, names.get (n, 'unnamed'))
849+
self.assertEqual(f.content, content [n])
850+
806851
def testMultipartKeepAlternatives(self):
807852
self.doNewIssue()
808853
self._handle_mail(self.multipart_msg)

0 commit comments

Comments
 (0)