diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-03-04 17:44:04 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-03-04 17:44:04 +0100 |
commit | 238be3bafed5c9f4aa8015c85ffe429fb698443a (patch) | |
tree | 53cd20a66d1714338a3a8e415c08f2cc14dbcf87 /alot/commands | |
parent | a558da1fd4ee9e3768ade72ea097704ad5dcd812 (diff) |
db/utils: drop decode_header()
It is almost entirely unnecessary - python's email messages decode the
headers themselves. Do the "normalization" bit directly in the single
place where it is done, though properly there should be more thorough
message text sanitization somewhere (most likely in our message
wrapper).
Diffstat (limited to 'alot/commands')
-rw-r--r-- | alot/commands/thread.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/alot/commands/thread.py b/alot/commands/thread.py index eb95a9bc..0e306eef 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -26,7 +26,6 @@ from .common import RetagPromptCommand from .envelope import SendCommand from ..completion.contacts import ContactsCompleter from ..completion.path import PathCompleter -from ..db.utils import decode_header from ..db.utils import formataddr from ..db.utils import extract_headers from ..db.utils import extract_body @@ -158,7 +157,7 @@ class ReplyCommand(Command): envelope = Envelope(bodytext=mailcontent, replied=self.message) # copy subject - subject = decode_header(mail.get('Subject', '')) + subject = mail.get('Subject', '') reply_subject_hook = settings.get_hook('reply_subject') if reply_subject_hook: subject = reply_subject_hook(subject) @@ -224,7 +223,7 @@ class ReplyCommand(Command): # copy cc for group-replies if 'Cc' in mail: cc = clear_my_address(account, mail.get_all('Cc', [])) - envelope.add('Cc', decode_header(', '.join(cc))) + envelope.add('Cc', ', '.join(cc)) to = ', '.join(ensure_unique_address(recipients)) logging.debug('reply to: %s', to) @@ -246,7 +245,7 @@ class ReplyCommand(Command): envelope.__delitem__('To') # Finally setup the 'To' header - envelope.add('To', decode_header(to)) + envelope.add('To', to) # if any of the recipients is a mailinglist that we are subscribed to, # set Mail-Followup-To header so that duplicates are avoided @@ -258,7 +257,7 @@ class ReplyCommand(Command): if any(addr in lists for n, addr in getaddresses(allrecipients)): followupto = ', '.join(allrecipients) logging.debug('mail followup to: %s', followupto) - envelope.add('Mail-Followup-To', decode_header(followupto)) + envelope.add('Mail-Followup-To', followupto) # set In-Reply-To header envelope.add('In-Reply-To', '<%s>' % self.message.id) @@ -347,7 +346,7 @@ class ForwardCommand(Command): envelope.attach(Attachment(original_mail)) # copy subject - subject = decode_header(mail.get('Subject', '')) + subject = mail.get('Subject', '') subject = 'Fwd: ' + subject forward_subject_hook = settings.get_hook('forward_subject') if forward_subject_hook: @@ -470,7 +469,7 @@ class EditNewCommand(Command): to_copy = ['Subject', 'From', 'To', 'Cc', 'Bcc', 'In-Reply-To', 'References'] for key in to_copy: - value = decode_header(mail.get(key, '')) + value = mail.get(key, '') if value: envelope.add(key, value) |