diff options
Diffstat (limited to 'alot')
-rw-r--r-- | alot/commands/thread.py | 13 | ||||
-rw-r--r-- | alot/db/utils.py | 28 | ||||
-rw-r--r-- | alot/widgets/thread.py | 7 |
3 files changed, 10 insertions, 38 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) diff --git a/alot/db/utils.py b/alot/db/utils.py index 86c4718b..8a96df14 100644 --- a/alot/db/utils.py +++ b/alot/db/utils.py @@ -323,7 +323,7 @@ def extract_headers(mail, headers=None): for key in headers: value = '' if key in mail: - value = decode_header(mail.get(key, '')) + value = mail.get(key, '') headertext += '%s: %s\n' % (key, value) return headertext @@ -474,32 +474,6 @@ def formataddr(pair): return "{0} <{1}>".format(name, address) -def decode_header(header, normalize=False): - """ - decode a header value to a unicode string - - values are usually a mixture of different substrings - encoded in quoted printable using different encodings. - This turns it into a single unicode string - - :param header: the header value - :type header: str - :param normalize: replace trailing spaces after newlines - :type normalize: bool - :rtype: str - """ - logging.debug("unquoted header: |%s|", header) - - valuelist = email.header.decode_header(header) - decoded_list = [] - for v, enc in valuelist: - v = string_decode(v, enc) - decoded_list.append(string_sanitize(v)) - value = ''.join(decoded_list) - if normalize: - value = re.sub(r'\n\s+', r' ', value) - return value - def is_subdir_of(subpath, superpath): # make both absolute diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py index 0096188d..db0af0e0 100644 --- a/alot/widgets/thread.py +++ b/alot/widgets/thread.py @@ -11,10 +11,9 @@ import urwid from .globals import TagWidget from .globals import AttachmentWidget from ..settings.const import settings -from ..db.utils import decode_header, X_SIGNATURE_MESSAGE_HEADER +from ..db.utils import X_SIGNATURE_MESSAGE_HEADER from ..helper import string_sanitize - class MessageSummaryWidget(urwid.WidgetWrap): """ one line summary of a :class:`~alot.db.message.Message`. @@ -60,7 +59,7 @@ class MessageSummaryWidget(urwid.WidgetWrap): mail = self.message.get_email() subj = mail.get_all('subject', ['']) - subj = ','.join([decode_header(s, normalize = True) for s in subj]) + subj = re.sub(r'\n\s+', r' ', ','.join(subj)) author, address = self.message.get_author() date = self.message.get_datestring() @@ -128,7 +127,7 @@ class HeadersWidget(urwid.WidgetWrap): # TODO even/odd keyw = ('fixed', max_key_len + 1, urwid.Text((self._key_attr, key))) - valuew = urwid.Text((self._value_attr, decode_header(value))) + valuew = urwid.Text((self._value_attr, value)) linew = urwid.AttrMap(urwid.Columns([keyw, valuew]), self._gaps_attr) widgets.append(linew) |