Skip to content

Commit

Permalink
fix MailMessage.subject
Browse files Browse the repository at this point in the history
  • Loading branch information
ikvk committed May 12, 2021
1 parent 8d7c835 commit 678f8e4
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ Big thanks to people who helped develop this library:
`daniel55411 <https://github.com/daniel55411>`_,
`rcarmo <https://github.com/rcarmo>`_,
`bhernacki <https://github.com/bhernacki>`_,
`ilep <https://github.com/ilep>`_
`ilep <https://github.com/ilep>`_,
`ThKue <https://github.com/ThKue>`_

Donate
------
Expand Down
4 changes: 4 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.41.0
======
* Fixed multiple encodings case bug at MailMessage.subject

0.40.0
======
* Fixed MailMessage.from_bytes - MailMessage.uid/flags parse errors
Expand Down
2 changes: 1 addition & 1 deletion imap_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .folder import MailBoxFolderManager, MailBoxFolderStatusOptions
from .errors import *

__version__ = '0.40.0'
__version__ = '0.41.0'
4 changes: 2 additions & 2 deletions imap_tools/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def flags(self) -> (str,):
def subject(self) -> str:
"""Message subject"""
if 'subject' in self.obj:
msg_subject = decode_header(self.obj['subject'])
return decode_value(msg_subject[0][0], msg_subject[0][1])
raw = self.obj['subject']
return ''.join(decode_value(*head_part) for head_part in decode_header(raw))
return ''

@property
Expand Down
2 changes: 1 addition & 1 deletion tests/messages_data/attachment_7bit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime

DATA = dict(
subject='статус',
subject='статус ',
from_='[email protected]',
to=('[email protected]', 'я你Rabea.Bartö[email protected]'),
cc=(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime

DATA = dict(
subject='Re: Test: ',
subject='Re: Test: "漢字" mid "漢字" tail',
from_='[email protected]',
to=('[email protected]',),
cc=(),
Expand Down
2 changes: 1 addition & 1 deletion tests/messages_data/rfc2822/example14.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime

DATA = dict(
subject='Re: TEST',
subject='Re: TESTテストテスト',
from_='[email protected]',
to=('[email protected]',),
cc=(),
Expand Down

0 comments on commit 678f8e4

Please sign in to comment.