aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-11-22 11:09:57 +0100
committerRobin Jarry <robin@jarry.cc>2022-11-23 10:44:01 +0100
commitfafcee2534111ee2f1353201837ca8cd42850e26 (patch)
tree34f4f22fe99601ee61156629c9fd7c53d6522313 /worker/imap
parent04869bd2a39abe7982428c00f5c024a89099f679 (diff)
downloadaerc-fafcee2534111ee2f1353201837ca8cd42850e26.tar.gz
imap: fix error with empty flag updates
Fix the following error occurring when fetching new headers after IDLE: panic: runtime error: invalid memory address or nil pointer dereference bufio.(*Reader).fill(0xc00029af00) bufio/bufio.go:106 +0xd8 bufio.(*Reader).Peek(0xc0006e1f00, 0x1) bufio/bufio.go:144 +0x5d github.com/emersion/go-message/textproto.ReadHeader(0x0?) github.com/emersion/go-message@v0.15.0/textproto/header.go:525 +0x5f git.sr.ht/~rjarry/aerc/worker/imap.(*IMAPWorker).handleFetchMessageHeaders.func1(0xc00026e980) git.sr.ht/~rjarry/aerc/worker/imap/fetch.go:49 +0x1ab git.sr.ht/~rjarry/aerc/worker/imap.(*IMAPWorker).handleFetchMessages.func1() git.sr.ht/~rjarry/aerc/worker/imap/fetch.go:222 +0xa2 created by git.sr.ht/~rjarry/aerc/worker/imap.(*IMAPWorker).handleFetchMessages git.sr.ht/~rjarry/aerc/worker/imap/fetch.go:217 +0x10a Some IMAP messages only contain flag updates, ignore them. Reuse the same logic than handleFetchMessageBodyPart() and handleFechFullMessages(). Fixes: https://todo.sr.ht/~rjarry/aerc/111 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: normen <normenweb@mac.com>
Diffstat (limited to 'worker/imap')
-rw-r--r--worker/imap/fetch.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/worker/imap/fetch.go b/worker/imap/fetch.go
index f3aad36e..f5407087 100644
--- a/worker/imap/fetch.go
+++ b/worker/imap/fetch.go
@@ -45,13 +45,17 @@ func (imapw *IMAPWorker) handleFetchMessageHeaders(
}
imapw.handleFetchMessages(msg, toFetch, items,
func(_msg *imap.Message) error {
+ if len(_msg.Body) == 0 {
+ // ignore duplicate messages with only flag updates
+ return nil
+ }
reader := _msg.GetBody(section)
+ if reader == nil {
+ return fmt.Errorf("failed to find part: %v", section)
+ }
textprotoHeader, err := textproto.ReadHeader(bufio.NewReader(reader))
if err != nil {
- logging.Errorf(
- "message %d: could not read header: %v", _msg.Uid, err)
- imapw.worker.PostMessageInfoError(msg, _msg.Uid, err)
- return nil
+ return fmt.Errorf("failed to read part header: %w", err)
}
header := &mail.Header{Header: message.Header{Header: textprotoHeader}}
info := &models.MessageInfo{