small pixel drawing of a pufferfish clist

Fix decoding bug
j3s j3s@c3f.net
Sun, 22 Dec 2019 13:20:37 -0600
commit

d1b6a7dccc89eea30e2890c3714596b6171e2fa0

parent

4fea84504e9b90f3a7c432f8e3a895089395c7c9

1 files changed, 16 insertions(+), 1 deletions(-)

jump to
M mail/main.gomail/main.go

@@ -173,6 +173,11 @@ if err != nil {

return textBody, htmlBody, embeddedFiles, err } + ContentTransferEncoding, params, err := mime.ParseMediaType(part.Header.Get("Content-Transfer-Encoding")) + if err != nil { + return textBody, htmlBody, embeddedFiles, err + } + switch contentType { case contentTypeTextPlain: ppContent, err := ioutil.ReadAll(part)

@@ -180,7 +185,17 @@ if err != nil {

return textBody, htmlBody, embeddedFiles, err } - textBody += strings.TrimSuffix(string(ppContent[:]), "\n") + txt := strings.TrimSuffix(string(ppContent[:]), "\n") + + if ContentTransferEncoding == "base64" { + b, err := base64.StdEncoding.DecodeString(txt) + if err != nil { + return textBody, htmlBody, embeddedFiles, err + } + txt = string(b) + } + + textBody += txt case contentTypeTextHtml: ppContent, err := ioutil.ReadAll(part) if err != nil {