mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
feat: migrate to gopenpgp v2
This commit is contained in:
@ -23,13 +23,13 @@ import (
|
||||
"io"
|
||||
"mime/quotedprintable"
|
||||
|
||||
pmcrypto "github.com/ProtonMail/gopenpgp/crypto"
|
||||
"github.com/ProtonMail/gopenpgp/v2/crypto"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
"github.com/emersion/go-textwrapper"
|
||||
openpgperrors "golang.org/x/crypto/openpgp/errors"
|
||||
)
|
||||
|
||||
func WriteBody(w io.Writer, kr *pmcrypto.KeyRing, m *pmapi.Message) error {
|
||||
func WriteBody(w io.Writer, kr *crypto.KeyRing, m *pmapi.Message) error {
|
||||
// Decrypt body.
|
||||
if err := m.Decrypt(kr); err != nil && err != openpgperrors.ErrSignatureExpired {
|
||||
return err
|
||||
@ -46,7 +46,7 @@ func WriteBody(w io.Writer, kr *pmcrypto.KeyRing, m *pmapi.Message) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func WriteAttachmentBody(w io.Writer, kr *pmcrypto.KeyRing, m *pmapi.Message, att *pmapi.Attachment, r io.Reader) (err error) {
|
||||
func WriteAttachmentBody(w io.Writer, kr *crypto.KeyRing, m *pmapi.Message, att *pmapi.Attachment, r io.Reader) (err error) {
|
||||
// Decrypt it
|
||||
var dr io.Reader
|
||||
dr, err = att.Decrypt(r, kr)
|
||||
|
||||
4
pkg/message/testdata/text_plain_bad_sender.eml
vendored
Normal file
4
pkg/message/testdata/text_plain_bad_sender.eml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
From: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <sender@pm.me>
|
||||
To: Receiver <receiver@pm.me>
|
||||
|
||||
body
|
||||
5
pkg/message/testdata/text_plain_bad_subject.eml
vendored
Normal file
5
pkg/message/testdata/text_plain_bad_subject.eml
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
From: Sender <sender@pm.me>
|
||||
To: Receiver <receiver@pm.me>
|
||||
Subject: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
body
|
||||
12
pkg/message/testdata/text_plain_plain_attachment_latin1.eml
vendored
Normal file
12
pkg/message/testdata/text_plain_plain_attachment_latin1.eml
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
From: Sender <sender@pm.me>
|
||||
To: Receiver <receiver@pm.me>
|
||||
Content-Type: multipart/mixed; boundary=longrandomstring
|
||||
|
||||
--longrandomstring
|
||||
|
||||
body
|
||||
--longrandomstring
|
||||
Content-Disposition: attachment
|
||||
|
||||
Aur<EFBFBD>lien is a latin1 name.
|
||||
--longrandomstring--
|
||||
12
pkg/message/testdata/text_plain_plain_attachment_latin2.eml
vendored
Normal file
12
pkg/message/testdata/text_plain_plain_attachment_latin2.eml
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
From: Sender <sender@pm.me>
|
||||
To: Receiver <receiver@pm.me>
|
||||
Content-Type: multipart/mixed; boundary=longrandomstring
|
||||
|
||||
--longrandomstring
|
||||
|
||||
body
|
||||
--longrandomstring
|
||||
Content-Disposition: attachment
|
||||
|
||||
Aur<EFBFBD>lien is a latin1 name but this document is latin2.
|
||||
--longrandomstring--
|
||||
Reference in New Issue
Block a user