From 0a1a75aed17e56c32cb0283e1b9f1978bd52fd7f Mon Sep 17 00:00:00 2001 From: ernierasta Date: Fri, 6 Dec 2019 00:58:54 +0100 Subject: [PATCH] fix non-utf8 encoding in msgviewer This patch should fix encoding problem with non-utf8 text/plain mime. It is now correctly convert to utf8 before sending to pager. It will also solve quoting such mails. Leszek --- widgets/msgviewer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go index aca7dd4..9d71c3e 100644 --- a/widgets/msgviewer.go +++ b/widgets/msgviewer.go @@ -10,7 +10,7 @@ import ( "strings" "github.com/danwakefield/fnmatch" - "github.com/emersion/go-message" + message "github.com/emersion/go-message" _ "github.com/emersion/go-message/charset" "github.com/emersion/go-message/mail" "github.com/gdamore/tcell" @@ -530,7 +530,7 @@ func (pv *PartViewer) attemptCopy() { if pv.source != nil && pv.pager != nil && pv.pager.Process != nil { header := message.Header{} header.SetText("Content-Transfer-Encoding", pv.part.Encoding) - header.SetContentType(pv.part.MIMEType, pv.part.Params) + header.SetContentType(fmt.Sprintf("%s/%s", pv.part.MIMEType, pv.part.MIMESubType), pv.part.Params) header.SetText("Content-Description", pv.part.Description) if pv.filter != nil { stdout, _ := pv.filter.StdoutPipe()