From 58db517c8d79c7fd8897d8ab5d5cf9c2de67a071 Mon Sep 17 00:00:00 2001 From: Ray Ganardi Date: Tue, 19 May 2020 13:06:46 +0200 Subject: pgp: fail gracefully from email decryption Aerc panics when there's an error on email decryption. Instead, an error message should be shown. --- lib/messageview.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/messageview.go b/lib/messageview.go index 59a1af6b..384a9472 100644 --- a/lib/messageview.go +++ b/lib/messageview.go @@ -59,7 +59,7 @@ type MessageStoreView struct { func NewMessageStoreView(messageInfo *models.MessageInfo, store *MessageStore, decryptKeys openpgp.PromptFunction, - cb func(MessageView)) { + cb func(MessageView, error)) { msv := &MessageStoreView{messageInfo, store, nil, nil, messageInfo.BodyStructure} @@ -69,26 +69,30 @@ func NewMessageStoreView(messageInfo *models.MessageInfo, reader := fm.Content.Reader pgpReader, err := pgpmail.Read(reader, Keyring, decryptKeys, nil) if err != nil { - panic(err) + cb(nil, err) + return } msv.message, err = ioutil.ReadAll(pgpReader.MessageDetails.UnverifiedBody) if err != nil { - panic(err) + cb(nil, err) + return } decrypted, err := message.Read(bytes.NewBuffer(msv.message)) if err != nil { - panic(err) + cb(nil, err) + return } bs, err := lib.ParseEntityStructure(decrypted) if err != nil { - panic(err) + cb(nil, err) + return } msv.bodyStructure = bs msv.details = pgpReader.MessageDetails - cb(msv) + cb(msv, nil) }) } else { - cb(msv) + cb(msv, nil) } store.Read([]uint32{messageInfo.Uid}, true, nil) } -- cgit