comparison test/test_mailgw.py @ 6345:14c9284a8bad

Fix filename created from mail attachments Fixes issue2551118
author Ralf Schlatterbeck <rsc@runtux.com>
date Wed, 17 Mar 2021 10:54:14 +0100
parents 778a9f455067
children 58817c3bf471
comparison
equal deleted inserted replaced
6344:c63df349f319 6345:14c9284a8bad
698 in latin-1 format =E4=F6=FC=C4=D6=DC=DF 698 in latin-1 format =E4=F6=FC=C4=D6=DC=DF
699 699
700 --uh56ypi7view24rr-- 700 --uh56ypi7view24rr--
701 ''' 701 '''
702 702
703 filename_msg = '''From: mary <mary@test.test>
704 To: issue_tracker@your.tracker.email.domain.example
705 Message-Id: <followup_dummy_id>
706 In-Reply-To: <dummy_test_message_id>
707 Subject: [issue1] Testing...
708 Content-Type: multipart/mixed; boundary="uh56ypi7view24rr"
709 Content-Disposition: inline
710
711 --uh56ypi7view24rr
712 Content-Type: text/plain; charset=us-ascii
713 Content-Disposition: inline
714
715 Attach a file with non-ascii characters in it (encoded latin-1 should
716 make it as-is through roundup due to Content-Type
717 application/octet-stream)
718 --
719 Ralf Schlatterbeck email: ralf@zoo.priv.at
720
721 --uh56ypi7view24rr
722 Content-Type: application/octet-stream
723 Content-Disposition: attachment;
724 filename==?iso-8859-1?Q?20210312=5FM=FCnchen=5FRepor?=
725 =?iso-8859-1?Q?t.pdf?=
726 Content-Transfer-Encoding: quoted-printable
727
728 This is a file containing text
729 in latin-1 format =E4=F6=FC=C4=D6=DC=DF
730
731 --uh56ypi7view24rr--
732 '''
733
703 multipart_msg = '''From: mary <mary@test.test> 734 multipart_msg = '''From: mary <mary@test.test>
704 To: issue_tracker@your.tracker.email.domain.example 735 To: issue_tracker@your.tracker.email.domain.example
705 Message-Id: <followup_dummy_id> 736 Message-Id: <followup_dummy_id>
706 In-Reply-To: <dummy_test_message_id> 737 In-Reply-To: <dummy_test_message_id>
707 Subject: [issue1] Testing... 738 Subject: [issue1] Testing...
841 messages = self.db.issue.get('1', 'messages') 872 messages = self.db.issue.get('1', 'messages')
842 messages.sort() 873 messages.sort()
843 msg = self.db.msg.getnode (messages[-1]) 874 msg = self.db.msg.getnode (messages[-1])
844 assert(len(msg.files) == 1) 875 assert(len(msg.files) == 1)
845 names = {0 : 'testfile'} 876 names = {0 : 'testfile'}
877 content = [b'''This is a file containing text
878 in latin-1 format \xE4\xF6\xFC\xC4\xD6\xDC\xDF
879 ''']
880 for n, id in enumerate (msg.files):
881 f = self.db.file.getnode (id)
882 self.assertEqual(f.name, names.get (n, 'unnamed'))
883 self.assertEqual(f.binary_content, content [n])
884
885 def testFileAttachWithUmlaut(self):
886 self.doNewIssue()
887 self._handle_mail(self.filename_msg)
888 messages = self.db.issue.get('1', 'messages')
889 messages.sort()
890 msg = self.db.msg.getnode (messages[-1])
891 assert(len(msg.files) == 1)
892 names = {0 : u'20210312_M\xfcnchen_Report.pdf'}
846 content = [b'''This is a file containing text 893 content = [b'''This is a file containing text
847 in latin-1 format \xE4\xF6\xFC\xC4\xD6\xDC\xDF 894 in latin-1 format \xE4\xF6\xFC\xC4\xD6\xDC\xDF
848 '''] 895 ''']
849 for n, id in enumerate (msg.files): 896 for n, id in enumerate (msg.files):
850 f = self.db.file.getnode (id) 897 f = self.db.file.getnode (id)

Roundup Issue Tracker: http://roundup-tracker.org/