mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 20:56:51 +00:00
Other: preserve message header in PGP/MIME passthrough message
This commit is contained in:
@ -219,7 +219,7 @@ func buildExternallyEncryptedRFC822(kr *crypto.KeyRing, msg *pmapi.Message, opts
|
||||
return nil, errors.Wrap(ErrDecryptionFailed, err.Error())
|
||||
}
|
||||
|
||||
return buildPGPMIMERFC822(msg)
|
||||
return buildPGPMIMERFC822(msg, opts)
|
||||
}
|
||||
|
||||
hdr := getMessageHeader(msg, opts)
|
||||
@ -254,8 +254,8 @@ func buildExternallyEncryptedRFC822(kr *crypto.KeyRing, msg *pmapi.Message, opts
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func buildPGPMIMERFC822(msg *pmapi.Message) ([]byte, error) {
|
||||
var hdr message.Header
|
||||
func buildPGPMIMERFC822(msg *pmapi.Message, opts JobOptions) ([]byte, error) {
|
||||
hdr := getMessageHeader(msg, opts)
|
||||
|
||||
hdr.SetContentType("multipart/encrypted", map[string]string{
|
||||
"boundary": newBoundary(msg.ID).gen(),
|
||||
|
||||
@ -1023,6 +1023,8 @@ func TestBuildCustomMessageEncrypted(t *testing.T) {
|
||||
foreignKR := tests.MakeKeyRing(t)
|
||||
msg := newTestMessage(t, foreignKR, "messageID", "addressID", "multipart/mixed", body, time.Date(2020, time.January, 1, 0, 0, 0, 0, time.UTC))
|
||||
|
||||
msg.Subject = "this is a subject to make sure we preserve subject"
|
||||
|
||||
// Tell the job to ignore decryption errors; a custom message will be returned instead of an error.
|
||||
res, err := b.NewJobWithOptions(
|
||||
context.Background(),
|
||||
@ -1033,6 +1035,7 @@ func TestBuildCustomMessageEncrypted(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
section(t, res).
|
||||
expectHeader(`Subject`, is(msg.Subject)).
|
||||
expectContentType(is(`multipart/encrypted`)).
|
||||
expectContentTypeParam(`protocol`, is(`application/pgp-encrypted`))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user