From 37186846db8389f5c4f6055943c66baf5192dd18 Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Thu, 6 Aug 2020 09:53:15 +0200 Subject: [PATCH] feat: wrap attachment lines as per rfc822 --- pkg/message/parser.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/message/parser.go b/pkg/message/parser.go index 10eefd41..a89f7624 100644 --- a/pkg/message/parser.go +++ b/pkg/message/parser.go @@ -30,6 +30,7 @@ import ( "github.com/ProtonMail/proton-bridge/pkg/message/parser" "github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/emersion/go-message" + "github.com/emersion/go-textwrapper" "github.com/jaytaylor/html2text" ) @@ -290,11 +291,13 @@ func attachPublicKey(p *parser.Part, key, keyName string) { h.Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%v.asc.pgp"`, keyName)) h.Set("Content-Transfer-Encoding", "base64") - // TODO: Split body at col width 72. + body := new(bytes.Buffer) + + textwrapper.NewRFC822(body).Write([]byte(key)) p.AddChild(&parser.Part{ Header: h, - Body: []byte(key), + Body: body.Bytes(), }) }