mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-18 16:17:03 +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 nil, errors.Wrap(ErrDecryptionFailed, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildPGPMIMERFC822(msg)
|
return buildPGPMIMERFC822(msg, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
hdr := getMessageHeader(msg, opts)
|
hdr := getMessageHeader(msg, opts)
|
||||||
@ -254,8 +254,8 @@ func buildExternallyEncryptedRFC822(kr *crypto.KeyRing, msg *pmapi.Message, opts
|
|||||||
return buf.Bytes(), nil
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildPGPMIMERFC822(msg *pmapi.Message) ([]byte, error) {
|
func buildPGPMIMERFC822(msg *pmapi.Message, opts JobOptions) ([]byte, error) {
|
||||||
var hdr message.Header
|
hdr := getMessageHeader(msg, opts)
|
||||||
|
|
||||||
hdr.SetContentType("multipart/encrypted", map[string]string{
|
hdr.SetContentType("multipart/encrypted", map[string]string{
|
||||||
"boundary": newBoundary(msg.ID).gen(),
|
"boundary": newBoundary(msg.ID).gen(),
|
||||||
|
|||||||
@ -1023,6 +1023,8 @@ func TestBuildCustomMessageEncrypted(t *testing.T) {
|
|||||||
foreignKR := tests.MakeKeyRing(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 := 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.
|
// Tell the job to ignore decryption errors; a custom message will be returned instead of an error.
|
||||||
res, err := b.NewJobWithOptions(
|
res, err := b.NewJobWithOptions(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
@ -1033,6 +1035,7 @@ func TestBuildCustomMessageEncrypted(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
section(t, res).
|
section(t, res).
|
||||||
|
expectHeader(`Subject`, is(msg.Subject)).
|
||||||
expectContentType(is(`multipart/encrypted`)).
|
expectContentType(is(`multipart/encrypted`)).
|
||||||
expectContentTypeParam(`protocol`, is(`application/pgp-encrypted`))
|
expectContentTypeParam(`protocol`, is(`application/pgp-encrypted`))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user