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
This commit is contained in:
ernierasta 2019-12-06 00:58:54 +01:00 committed by Drew DeVault
parent cd54bcd041
commit 0a1a75aed1

View file

@ -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()