summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-06-01 14:30:56 -0700
committerDylan Baker <dylan@pnwbakers.com>2018-03-01 10:34:56 -0800
commit9a5f18920e7c304bfaee842ea4600b972e600ee6 (patch)
tree1e0e664b86574af7b6cd25131f42a4f5ebb2c7fc /alot
parent788bd5af30ecee5c54b1039171b77765c3f340a8 (diff)
hack alot.db.utils.decode_header until it works.
Diffstat (limited to 'alot')
-rw-r--r--alot/db/utils.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/alot/db/utils.py b/alot/db/utils.py
index 39bd9007..7fe24bd5 100644
--- a/alot/db/utils.py
+++ b/alot/db/utils.py
@@ -400,15 +400,15 @@ def decode_header(header, normalize=False):
This turns it into a single unicode string
:param header: the header value
- :type header: str
+ :type header: bytes
:param normalize: replace trailing spaces after newlines
:type normalize: bool
:rtype: str
"""
+ # FIXME: this is just hacked until it works, mostly
# If the value isn't ascii as RFC2822 prescribes,
# we just return the unicode bytestring as is
- # XXX: this prbably isn't going to work in python 3
value = string_decode(header) # convert to unicode
try:
value = value.encode('ascii')
@@ -418,12 +418,12 @@ def decode_header(header, normalize=False):
# some mailers send out incorrectly escaped headers
# and double quote the escaped realname part again. remove those
# RFC: 2047
- regex = r'"(=\?.+?\?.+?\?[^ ?]+\?=)"'
- value = re.sub(regex, r'\1', value)
- logging.debug("unquoted header: |%s|", value)
+ regex = br'"(=\?.+?\?.+?\?[^ ?]+\?=)"'
+ value = re.sub(regex, br'\1', value)
+ logging.debug(b"unquoted header: |%s|", value)
# otherwise we interpret RFC2822 encoding escape sequences
- valuelist = email.header.decode_header(value)
+ valuelist = email.header.decode_header(value.decode('ascii'))
decoded_list = []
for v, enc in valuelist:
v = string_decode(v, enc)