aboutsummaryrefslogtreecommitdiff
path: root/worker/imap
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-01-19 00:59:20 +0100
committerDrew DeVault <sir@cmpwn.com>2020-01-18 19:00:02 -0500
commit472c421e85fafbd2905e785852d04a7c0ab1e60a (patch)
tree85064ee861b731bdc80daccb75abe926fff9108d /worker/imap
parent686ca244052389b7815f7f2d73391e5f4c2b1ad7 (diff)
worker/imap: don't decode in FetchFullMessage.
Doing that breaks `git am` as it expected the encoded variant. Same is probably true for any sort of signature validation (gpg / dkim)
Diffstat (limited to 'worker/imap')
-rw-r--r--worker/imap/fetch.go29
1 files changed, 2 insertions, 27 deletions
diff --git a/worker/imap/fetch.go b/worker/imap/fetch.go
index 74ac482..bf60aa9 100644
--- a/worker/imap/fetch.go
+++ b/worker/imap/fetch.go
@@ -2,7 +2,6 @@ package imap
import (
"bufio"
- "bytes"
"encoding/base64"
"fmt"
"io"
@@ -61,6 +60,7 @@ func (imapw *IMAPWorker) handleFetchFullMessages(
imapw.worker.Logger.Printf("Fetching full messages")
section := &imap.BodySectionName{}
items := []imap.FetchItem{
+ imap.FetchEnvelope,
imap.FetchFlags,
imap.FetchUid,
section.FetchItem(),
@@ -103,16 +103,11 @@ func (imapw *IMAPWorker) handleFetchMessages(
done <- fmt.Errorf("could not get section %#v", section)
return
}
- reader, err := fullReader(r)
- if err != nil {
- done <- fmt.Errorf("could not read mail %#v", section)
- return
- }
imapw.worker.PostMessage(&types.FullMessage{
Message: types.RespondTo(msg),
Content: &models.FullMessage{
- Reader: reader,
+ Reader: bufio.NewReader(r),
Uid: _msg.Uid,
},
}, nil)
@@ -191,26 +186,6 @@ func getDecodedPart(task *types.FetchMessageBodyPart, msg *imap.Message,
return r, err
}
-func fullReader(r io.Reader) (io.Reader, error) {
- // parse the header for the encoding and also return it in the reader
- br := bufio.NewReader(r)
- textprotoHeader, err := textproto.ReadHeader(br)
- if err != nil {
- return nil, err
- }
- header := &mail.Header{message.Header{textprotoHeader}}
- enc := header.Get("Content-Transfer-Encoding")
-
- var buf bytes.Buffer
- err = textproto.WriteHeader(&buf, textprotoHeader)
- if err != nil {
- return nil, err
- }
- er := encodingReader(enc, br)
- full := io.MultiReader(&buf, er)
- return full, nil
-}
-
func encodingReader(encoding string, r io.Reader) io.Reader {
reader := r
// email parts are encoded as 7bit (plaintext), quoted-printable, or base64