From 7df0c95339cd16d6811933162e29c687da413598 Mon Sep 17 00:00:00 2001 From: Steve Cliff Date: Sun, 21 Jun 2026 23:53:24 +0100 Subject: [PATCH] fix(mail): propagate io.ReadAll errors when parsing parts --- internal/mail/message.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/mail/message.go b/internal/mail/message.go index ae1fd1b..c07dc3b 100644 --- a/internal/mail/message.go +++ b/internal/mail/message.go @@ -3,6 +3,7 @@ package mail import ( "bytes" + "fmt" "io" "strings" @@ -72,13 +73,19 @@ func ParseMessage(uid uint32, raw []byte) (Message, error) { case *mail.InlineHeader: ct, _, _ := hdr.ContentType() if strings.HasPrefix(ct, "text/plain") && m.BodyText == "" { - b, _ := io.ReadAll(part.Body) + b, err := io.ReadAll(part.Body) + if err != nil { + return Message{}, fmt.Errorf("read message part: %w", err) + } m.BodyText = string(b) } case *mail.AttachmentHeader: name, _ := hdr.Filename() ct, _, _ := hdr.ContentType() - b, _ := io.ReadAll(part.Body) + b, err := io.ReadAll(part.Body) + if err != nil { + return Message{}, fmt.Errorf("read message part: %w", err) + } m.Attachments = append(m.Attachments, Attachment{ Name: name, Size: len(b), MIME: ct, Content: b, })