aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-02-04 09:14:53 +0100
committerRobin Jarry <robin@jarry.cc>2022-02-06 16:04:15 +0100
commita46468521bf8a6d7f6f0d8f0728eb99d599d2ccf (patch)
tree5f535acde5f515a369cb43b73e4be786a4ad3024 /worker/imap
parent9fba8d9cbd4d8543fd35bddc0d64cc6f1a96ce00 (diff)
downloadaerc-a46468521bf8a6d7f6f0d8f0728eb99d599d2ccf.tar.gz
imap: do not abort on malformed messages
Some messages contain invalid headers, textproto.ReadHeader fails with an error: malformed MIME header key: From nobody Fri Jan 14 19 And all other messages of the selected folder are ignored. Return an explicit error message to the UI and continue processing other messages. This is consistent with what the maildir worker does. Signed-off-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/imap')
-rw-r--r--worker/imap/fetch.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/worker/imap/fetch.go b/worker/imap/fetch.go
index c63ee42a..19f4fa3d 100644
--- a/worker/imap/fetch.go
+++ b/worker/imap/fetch.go
@@ -38,7 +38,13 @@ func (imapw *IMAPWorker) handleFetchMessageHeaders(
reader := _msg.GetBody(section)
textprotoHeader, err := textproto.ReadHeader(bufio.NewReader(reader))
if err != nil {
- return fmt.Errorf("could not read header: %v", err)
+ imapw.worker.Logger.Printf(
+ "message %v: could not read header: %v", _msg.Uid, err)
+ imapw.worker.PostMessage(&types.Error{
+ Message: types.RespondTo(msg),
+ Error: err,
+ }, nil)
+ return nil
}
header := &mail.Header{message.Header{textprotoHeader}}
imapw.worker.PostMessage(&types.MessageInfo{