From 454d2488192bd334a4d4cb050f3d68a6406d0171 Mon Sep 17 00:00:00 2001 From: James Houlahan Date: Tue, 13 Apr 2021 17:26:52 +0200 Subject: [PATCH] GODT-213: Preserve contenttype for undecryptable message body --- pkg/message/build_rfc822_custom.go | 3 +-- pkg/message/build_test.go | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/pkg/message/build_rfc822_custom.go b/pkg/message/build_rfc822_custom.go index 89b47b6a..e7ab46b8 100644 --- a/pkg/message/build_rfc822_custom.go +++ b/pkg/message/build_rfc822_custom.go @@ -48,8 +48,7 @@ func writeCustomTextPart( var hdr message.Header - // Even if it is HTML, we don't care... we abuse pgp/inline here. - hdr.SetContentType("text/plain", nil) + hdr.SetContentType(msg.MIMEType, nil) part, err := w.CreatePart(hdr) if err != nil { diff --git a/pkg/message/build_test.go b/pkg/message/build_test.go index bfeab1fb..f569bc3a 100644 --- a/pkg/message/build_test.go +++ b/pkg/message/build_test.go @@ -1001,9 +1001,8 @@ func TestBuildCustomMessageHTML(t *testing.T) { section(t, res). expectContentType(is(`multipart/mixed`)) - // Even if it is HTML, we don't care... we abuse pgp/inline here. section(t, res, 1). - expectContentType(is(`text/plain`)). + expectContentType(is(`text/html`)). expectBody(contains(`This message could not be decrypted`)). expectBody(decryptsTo(foreignKR, `body`)). expectTransferEncoding(isMissing()) @@ -1076,9 +1075,8 @@ func TestBuildCustomMessageHTMLWithAttachment(t *testing.T) { section(t, res). expectContentType(is(`multipart/mixed`)) - // Even if it is HTML, we don't care... we abuse pgp/inline here. section(t, res, 1). - expectContentType(is(`text/plain`)). + expectContentType(is(`text/html`)). expectBody(contains(`This message could not be decrypted`)). expectBody(decryptsTo(foreignKR, `body`)). expectTransferEncoding(isMissing()) @@ -1120,9 +1118,8 @@ func TestBuildCustomMessageOnlyBodyIsUndecryptable(t *testing.T) { section(t, res). expectContentType(is(`multipart/mixed`)) - // Even if it is HTML, we don't care... we abuse pgp/inline here. section(t, res, 1). - expectContentType(is(`text/plain`)). + expectContentType(is(`text/html`)). expectBody(contains(`This message could not be decrypted`)). expectBody(decryptsTo(foreignKR, `body`)). expectTransferEncoding(isMissing())