thunderbird-android icon indicating copy to clipboard operation
thunderbird-android copied to clipboard

Unparseable dates should be handled more gracefully

Open gregrenda opened this issue 1 year ago • 5 comments

Checklist

  • [x] I have used the search function to see if someone else has already submitted the same bug report.
  • [x] I will describe the problem with as much detail as possible.

App

K-9 Mail

App version

8.2

Where did you get the app from?

Google Play

Android version

14

Device model

AGM_PAD_P2

Steps to reproduce

Attempt to retrieve a message with an unparseable date.

Expected behavior

Ideally, the message will be retrieved and displayed with some indication of the problem. At a minimum, the message should be ignored.

Actual behavior

An exception is thrown and none of the retrieved messages are displayed.

Logs

01-03 10:59:35.108 14049 14074 E ImapSync: synchronizeMailbox
01-03 10:59:35.108 14049 14074 E ImapSync: com.fsck.k9.mail.MessagingException: Unable to parse IMAP datetime 'Tue, 31 Dec 2024 23:00:02 +9900' 
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.mail.store.imap.ImapList.getDate(ImapList.java:86)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.mail.store.imap.ImapList.getKeyedDate(ImapList.java:76)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.mail.store.imap.RealImapFolder.handleFetchResponse(RealImapFolder.kt:760)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.mail.store.imap.RealImapFolder.fetch(RealImapFolder.kt:623)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.backend.imap.ImapSync.fetchUnsyncedMessages(ImapSync.kt:461)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.backend.imap.ImapSync.downloadMessages(ImapSync.kt:331)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.backend.imap.ImapSync.synchronizeMailboxSynchronous(ImapSync.kt:203)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.backend.imap.ImapSync.sync(ImapSync.kt:34)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.backend.imap.ImapBackend.sync(ImapBackend.kt:56)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.controller.MessagingController.syncFolder(MessagingController.java:638)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.controller.MessagingController.synchronizeMailboxSynchronous(MessagingController.java:578)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.controller.MessagingController.loadMoreMessagesSynchronous(MessagingController.java:542)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.controller.MessagingController.lambda$loadMoreMessages$4(MessagingController.java:526)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.controller.MessagingController.$r8$lambda$R4JompHX5lAPJKWcyY6ODgWeMTs(MessagingController.java:0)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.controller.MessagingController$$ExternalSyntheticLambda21.run(R8$$SyntheticClass:0)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.controller.MessagingController.runInBackground(MessagingController.java:221)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.controller.MessagingController.-$$Nest$mrunInBackground(MessagingController.java:0)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.controller.MessagingController$1.run(MessagingController.java:162)
01-03 10:59:35.108 14049 14074 E ImapSync:      at java.lang.Thread.run(Thread.java:1012)
01-03 10:59:35.108 14049 14074 E ImapSync: Caused by: java.text.ParseException: Unparseable date: "Tue, 31 Dec 2024 23:00:02 +9900"
01-03 10:59:35.108 14049 14074 E ImapSync:      at java.text.DateFormat.parse(DateFormat.java:400)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.mail.store.imap.ImapList.parseDate(ImapList.java:157)
01-03 10:59:35.108 14049 14074 E ImapSync:      at com.fsck.k9.mail.store.imap.ImapList.getDate(ImapList.java:84)
01-03 10:59:35.108 14049 14074 E ImapSync:      ... 18 more
01-03 10:59:35.117 14049 14074 E ImapSync: Failed synchronizing folder [email protected]:INBOX @ Fri Jan 03 10:59:35 PST 2025

gregrenda avatar Jan 03 '25 19:01 gregrenda

This exception is not about the Date header field of a message. It's the internal date of the IMAP message. See RFC 3501, section 2.3.3.

Not using the proper date format is a bug that should be fixed on the server side. Please inform the operator of your mail server.

cketti avatar Jan 04 '25 00:01 cketti

I understand that the server is providing an erroneous date. I'm suggesting that rather than essentially silently failing some error indication and workaround could be provided. What if the mail server operator is unable to fix the problem in a timely manner? Then you're stuck unable to read your mail.

gregrenda avatar Jan 04 '25 00:01 gregrenda

I think we can be more lenient in that we wouldn't break sync, but as the burden should be on server authors let's just fall back to 1970-01-01 if possible. I don't think we should maintain code to work around these issues.

@gregrenda do you know which server is being used here?

kewisch avatar Mar 11 '25 20:03 kewisch

This is my own custom server. My server was passing along the date from the message. I know this is not what the RFC says but my server provides a gateway for messages stored in MH (https://en.wikipedia.org/wiki/MH_Message_Handling_System) format and that's all I had.

gregrenda avatar Mar 12 '25 17:03 gregrenda

This doesn't address how things will be handled with different locales and lacks unit tests. In addition we are avoiding handling custom server date formats and sticking to standard Mime4j date formats. We won't be accepting this at this time, but thank you for your interest in helping Thunderbird.

jbott-tbird avatar Jul 09 '26 14:07 jbott-tbird