feat: wrap attachment lines as per rfc822

This commit is contained in:
James Houlahan
2020-08-06 09:53:15 +02:00
parent a5a61c9428
commit 37186846db

View File

@ -30,6 +30,7 @@ import (
"github.com/ProtonMail/proton-bridge/pkg/message/parser" "github.com/ProtonMail/proton-bridge/pkg/message/parser"
"github.com/ProtonMail/proton-bridge/pkg/pmapi" "github.com/ProtonMail/proton-bridge/pkg/pmapi"
"github.com/emersion/go-message" "github.com/emersion/go-message"
"github.com/emersion/go-textwrapper"
"github.com/jaytaylor/html2text" "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-Disposition", fmt.Sprintf(`attachment; filename="%v.asc.pgp"`, keyName))
h.Set("Content-Transfer-Encoding", "base64") 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{ p.AddChild(&parser.Part{
Header: h, Header: h,
Body: []byte(key), Body: body.Bytes(),
}) })
} }