diff options
Diffstat (limited to 'alot/db')
-rw-r--r-- | alot/db/__init__.py | 2 | ||||
-rw-r--r-- | alot/db/message.py | 12 | ||||
-rw-r--r-- | alot/db/utils.py | 6 |
3 files changed, 15 insertions, 5 deletions
diff --git a/alot/db/__init__.py b/alot/db/__init__.py index 86f56b5d..95d2b245 100644 --- a/alot/db/__init__.py +++ b/alot/db/__init__.py @@ -191,6 +191,7 @@ class DBManager(object): :exception: :exc:`~errors.DatabaseROError` .. note:: + This only adds the requested operation to the write queue. You need to call :meth:`DBManager.flush` to actually write out. """ if self.ro: @@ -216,6 +217,7 @@ class DBManager(object): :exception: :exc:`~errors.DatabaseROError` .. note:: + This only adds the requested operation to the write queue. You need to call :meth:`DBManager.flush` to actually write out. """ if self.ro: diff --git a/alot/db/message.py b/alot/db/message.py index 9ab67db3..ecd94277 100644 --- a/alot/db/message.py +++ b/alot/db/message.py @@ -8,6 +8,7 @@ import alot.helper as helper from alot.settings import settings from utils import extract_headers, extract_body +from alot.db.utils import decode_header from attachment import Attachment @@ -34,8 +35,9 @@ class Message(object): self._datetime = helper.safely_get(casts_date, ValueError, None) self._filename = msg.get_filename() - self._from = helper.safely_get(lambda: msg.get_header('From'), + author = helper.safely_get(lambda: msg.get_header('From'), NullPointerError) + self._from = decode_header(author) self._email = None # will be read upon first use self._attachments = None # will be read upon first use self._tags = set(msg.get_tags()) @@ -118,10 +120,12 @@ class Message(object): def get_datestring(self): """ - returns reformated datestring for this messages. + returns reformated datestring for this message. - It uses the format spacified by `timestamp_format` in - the general section of the config. + It uses :meth:`SettingsManager.represent_datetime` to represent + this messages `Date` header + + :rtype: str """ if self._datetime == None: res = None diff --git a/alot/db/utils.py b/alot/db/utils.py index e9d40c21..5ff02c5d 100644 --- a/alot/db/utils.py +++ b/alot/db/utils.py @@ -132,8 +132,12 @@ def decode_header(header, normalize=False): except UnicodeEncodeError: return value + # some mailers send out incorrectly escaped headers + # and double quote the escaped realname part again. remove those + value = re.sub(r'\"(.*?=\?.*?.*?)\"', r'\1', value) + # otherwise we interpret RFC2822 encoding escape sequences - valuelist = email.header.decode_header(header) + valuelist = email.header.decode_header(value) decoded_list = [] for v, enc in valuelist: v = string_decode(v, enc) |