aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-10-19 22:23:13 +0200
committerRobin Jarry <robin@jarry.cc>2022-10-19 23:52:44 +0200
commite055089d2f3478735c6d3fa85e99e9dc10a62731 (patch)
treeb2ad521291bc3a20f1e133dd7ca12760343fea70 /lib
parent7585a54832cc045962a769b65861bf174202b891 (diff)
downloadaerc-e055089d2f3478735c6d3fa85e99e9dc10a62731.tar.gz
lib: fallback on raw msg when decoding fails
Avoid panic when part decoding fails: panic: quotedprintable: invalid unescaped byte 0x0c in body User-friendlier fallback when a (decoding) error occurs while reading a message part. Link: https://lists.sr.ht/~rjarry/aerc-discuss/%3CCNJRVKUG8T68.3TVA2T10DTTBA%40guix-framework%3E Reported-by: "(" <paren@disroot.org> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib')
-rw-r--r--lib/messageview.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/messageview.go b/lib/messageview.go
index e4f9cbeb..247cecbe 100644
--- a/lib/messageview.go
+++ b/lib/messageview.go
@@ -2,12 +2,15 @@ package lib
import (
"bytes"
+ "fmt"
"io"
+ "strings"
"github.com/ProtonMail/go-crypto/openpgp"
_ "github.com/emersion/go-message/charset"
"git.sr.ht/~rjarry/aerc/lib/crypto"
+ "git.sr.ht/~rjarry/aerc/logging"
"git.sr.ht/~rjarry/aerc/models"
"git.sr.ht/~rjarry/aerc/worker/lib"
"git.sr.ht/~rjarry/aerc/worker/types"
@@ -140,7 +143,14 @@ func (msv *MessageStoreView) FetchBodyPart(part []int, cb func(io.Reader)) {
}
reader, err := lib.FetchEntityPartReader(msg, part)
if err != nil {
- panic(err)
+ errMsg := fmt.Errorf("Failed to fetch message part: %w", err)
+ logging.Errorf(errMsg.Error())
+ if msv.message != nil {
+ logging.Warnf("Displaying raw message part")
+ reader = bytes.NewReader(msv.message)
+ } else {
+ reader = strings.NewReader(errMsg.Error())
+ }
}
cb(reader)
}