docker-offlineimap/offlineimap
Adam Dinwoodie 416df5d7c2 Skip parsing date after failing to parse the date
When file_use_mail_timestamp or utime_from_header are enabled,
OfflineIMAP tries to parse the Date header in the email.  If the header
is present but invalid -- it doesn't contain a valid date -- this will
cause email.message to raise an exception.  This is all fine.  However
when handling that exception, OfflineIMAP can't try to extract the date
again: it's clearly invalid, and raising the same exception a second
time while handling the first exception just causes the entire sync to
fail.

To avoid that happening, don't try to provide the invalid date string in
the error message.  Instead, just give the user the UID of the email
that triggered the exception, and the exception text.

Ideally we'd instead fix the code to actually extract the header value
and provide it in the error message, but Python's email.message module
doesn't provide an easy way to get the raw text of the Date header from
an EmailMessage object; it's possible using private variables like
EmailMessage._headers, or by parsing the email using a custom
email.policy.EmailPolicy object that disables the module's attempts to
coerce the header value to a DateTime.  However, a user should be able
to get the problematic Date header from the message directly anyway, so
it's not worth adding all that complexity for something that should be
rare and provides little value.

Fixes #134

Signed-off-by: Adam Dinwoodie <adam@dinwoodie.org>
2022-08-25 16:26:57 +01:00
..
folder Skip parsing date after failing to parse the date 2022-08-25 16:26:57 +01:00
repository Allow filtering of folders with spaces 2022-03-22 00:46:39 -04:00
ui Include offlineimap and pid in non interactive logs 2021-10-12 18:00:51 +02:00
utils distro_utils.py renamed variable f 2020-11-01 08:31:47 +01:00
__init__.py v8.0.0 2021-10-18 15:00:16 +02:00
accounts.py Communicate syncmode to synchooks 2021-09-07 09:43:16 +02:00
CustomConfig.py six: changed offlineimap/CustomConfig.py 2020-09-03 21:35:54 +02:00
error.py Reformat offlineimap/error.py 2020-08-29 20:15:55 +02:00
globals.py Reformat offlineimap/globals.py 2020-08-29 20:16:35 +02:00
imaplibutil.py Handle socks connection errors 2021-08-07 20:57:46 +02:00
imapserver.py Merge pull request #86 from dopefishh/communicate-syncmode-to-synchooks 2022-03-25 11:43:10 +01:00
imaputil.py fix imap4-utf-7 decoding errors 2022-03-25 18:29:43 +08:00
init.py Do not use UNIX signals in Windows 2021-07-25 15:53:09 +02:00
localeval.py localeval.py removed extra parenthesys 2020-08-30 18:52:56 +02:00
mbnames.py mbnames.py removed extra parenthesys 2020-08-30 18:53:02 +02:00
threadutil.py Removed doxygen param 2020-10-10 14:50:47 +02:00