summaryrefslogtreecommitdiff
path: root/alot/db
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-03-04 17:44:04 +0100
committerAnton Khirnov <anton@khirnov.net>2020-03-04 17:44:04 +0100
commit238be3bafed5c9f4aa8015c85ffe429fb698443a (patch)
tree53cd20a66d1714338a3a8e415c08f2cc14dbcf87 /alot/db
parenta558da1fd4ee9e3768ade72ea097704ad5dcd812 (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/db')
-rw-r--r--alot/db/utils.py28
1 files changed, 1 insertions, 27 deletions
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