File tree 2 files changed +26
-3
lines changed 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -724,9 +724,7 @@ def get_filename(self):
724
724
"""Returns the original filename of this attachment."""
725
725
file_name = self ._get_rehydrated_headers ().get_filename ()
726
726
if isinstance (file_name , six .text_type ):
727
- return file_name
728
- elif file_name :
729
- return convert_header_to_unicode (file_name )
727
+ return utils .convert_header_to_unicode (file_name )
730
728
else :
731
729
return None
732
730
Original file line number Diff line number Diff line change @@ -40,6 +40,31 @@ def test_message_without_attachments(self):
40
40
'Adam Coddington <[email protected] >' ,
41
41
)
42
42
43
+ def test_message_with_encoded_attachment_filenames (self ):
44
+ message = self ._get_email_object (
45
+ 'message_with_koi8r_filename_attachments.eml'
46
+ )
47
+
48
+ mailbox = Mailbox .objects .create ()
49
+ msg = mailbox .process_incoming_message (message )
50
+
51
+ attachments = msg .attachments .order_by ('pk' ).all ()
52
+ self .assertEqual (
53
+ '\u041f \u0430 \u043a \u0435 \u0442 \u043f \u0440 \u0435 \u0434 \u043b '
54
+ '\u043e \u0436 \u0435 \u043d \u0438 \u0439 HSE Career Fair 8 \u0430 '
55
+ '\u043f \u0440 \u0435 \u043b \u044f 2016.pdf' ,
56
+ attachments [0 ].get_filename ()
57
+ )
58
+ self .assertEqual (
59
+ '\u0412 \u0435 \u0434 \u043e \u043c \u043e \u0441 \u0442 \u0438 .pdf' ,
60
+ attachments [1 ].get_filename ()
61
+ )
62
+ self .assertEqual (
63
+ '\u041f \u0430 \u043a \u0435 \u0442 \u043f \u0440 \u0435 \u0434 \u043b '
64
+ '\u043e \u0436 \u0435 \u043d \u0438 \u0439 2016.pptx' ,
65
+ attachments [2 ].get_filename ()
66
+ )
67
+
43
68
def test_message_with_attachments (self ):
44
69
message = self ._get_email_object ('message_with_attachment.eml' )
45
70
You can’t perform that action at this time.
0 commit comments