aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/messageview.go2
-rw-r--r--worker/lib/parse.go11
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/messageview.go b/lib/messageview.go
index 8db7994a..f221fb2c 100644
--- a/lib/messageview.go
+++ b/lib/messageview.go
@@ -69,7 +69,7 @@ func NewMessageStoreView(messageInfo *models.MessageInfo,
if usePGP(messageInfo.BodyStructure) {
store.FetchFull([]uint32{messageInfo.Uid}, func(fm *types.FullMessage) {
- reader := fm.Content.Reader
+ reader := lib.NewCRLFReader(fm.Content.Reader)
pgpReader, err := pgpmail.Read(reader, Keyring, decryptKeys, nil)
if err != nil {
cb(nil, err)
diff --git a/worker/lib/parse.go b/worker/lib/parse.go
index 1c0e413c..5d95046c 100644
--- a/worker/lib/parse.go
+++ b/worker/lib/parse.go
@@ -1,6 +1,7 @@
package lib
import (
+ "bufio"
"bytes"
"errors"
"fmt"
@@ -271,3 +272,13 @@ func MessageInfo(raw RawMessage) (*models.MessageInfo, error) {
Error: parseErr,
}, nil
}
+
+// NewCRLFReader returns a reader with CRLF line endings
+func NewCRLFReader(r io.Reader) io.Reader {
+ var buf bytes.Buffer
+ scanner := bufio.NewScanner(r)
+ for scanner.Scan() {
+ buf.WriteString(scanner.Text() + "\r\n")
+ }
+ return &buf
+}