diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-11-16 10:07:24 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-11-16 10:10:12 +0100 |
| commit | 95cf3e724785cf8d46beec31c4a009b5a4c6af91 (patch) | |
| tree | be067a2541a567c7743b829a3a3884e76bcbc401 /pkg/email/parser.go | |
| parent | 447a290a8c920f719f82e863277a645df65e1a43 (diff) | |
pkg/email: fix base64-encoded body parsing
We currently handle base64 only for attachments,
but text/plain body can also be base64-encoded.
Diffstat (limited to 'pkg/email/parser.go')
| -rw-r--r-- | pkg/email/parser.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg/email/parser.go b/pkg/email/parser.go index c000625b5..275403960 100644 --- a/pkg/email/parser.go +++ b/pkg/email/parser.go @@ -195,12 +195,12 @@ func parseBody(r io.Reader, headers mail.Header) (body []byte, attachments [][]b if err != nil { return nil, nil, fmt.Errorf("failed to parse email header 'Content-Type': %v", err) } + // Note: mime package handles quoted-printable internally. + if strings.ToLower(headers.Get("Content-Transfer-Encoding")) == "base64" { + r = base64.NewDecoder(base64.StdEncoding, r) + } disp, _, _ := mime.ParseMediaType(headers.Get("Content-Disposition")) if disp == "attachment" { - // Note: mime package handles quoted-printable internally. - if strings.ToLower(headers.Get("Content-Transfer-Encoding")) == "base64" { - r = base64.NewDecoder(base64.StdEncoding, r) - } attachment, err := ioutil.ReadAll(r) if err != nil { return nil, nil, fmt.Errorf("failed to read email body: %v", err) |
