open: fix mimetype discovery for encrypted or signed messages

Mimetype discovery for the :open command is based on the BodyStructure
of the message. This patch fixes the method which got the BodyStructure
of the message to a more generalized one, which is set post-encryption
and post-validation. This allows encrypted or signed message parts to
have their proper mimetype discovered.

Fixes: https://todo.sr.ht/~rjarry/aerc/50
Reported-by: ~ph14nix
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Koni Marti <koni.marti@gmail.com>
This commit is contained in:
Tim Culverhouse 2022-06-25 07:40:10 -05:00 committed by Robin Jarry
parent 5205951149
commit 96db50c4f0
1 changed files with 1 additions and 1 deletions

View File

@ -52,7 +52,7 @@ func (Open) Execute(aerc *widgets.Aerc, args []string) error {
mv.MessageView().FetchBodyPart(p.Index, func(reader io.Reader) { mv.MessageView().FetchBodyPart(p.Index, func(reader io.Reader) {
extension := "" extension := ""
// try to determine the correct extension based on mimetype // try to determine the correct extension based on mimetype
if part, err := p.Msg.BodyStructure.PartAtIndex(p.Index); err == nil { if part, err := mv.MessageView().BodyStructure().PartAtIndex(p.Index); err == nil {
mimeType := fmt.Sprintf("%s/%s", part.MIMEType, part.MIMESubType) mimeType := fmt.Sprintf("%s/%s", part.MIMEType, part.MIMESubType)
if exts, _ := mime.ExtensionsByType(mimeType); len(exts) > 0 { if exts, _ := mime.ExtensionsByType(mimeType); len(exts) > 0 {