From 181068766c489475307a4cf7a0f120772ab40d2c Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Thu, 19 Aug 2021 23:27:16 +0200 Subject: [PATCH 1/2] Fix FilterActionEncryptTest, workaround now expired key in test data --- src/filter/autotests/gpghome/gpg.conf | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/filter/autotests/gpghome/gpg.conf diff --git a/src/filter/autotests/gpghome/gpg.conf b/src/filter/autotests/gpghome/gpg.conf new file mode 100644 index 0000000..228993a --- /dev/null +++ b/src/filter/autotests/gpghome/gpg.conf @@ -0,0 +1,3 @@ +# TODO: replace test keys with some which do not expire +# so this special setup is not needed and the test can check normal operation +faked-system-time 20180110T154812 From 17197c848caec74d070b2c3e05f87799aaf0c0c5 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Mon, 16 Aug 2021 17:48:55 +0200 Subject: [PATCH 2/2] Fix CryptoUtils::assembleMessage() to not add bogus text/plain content-type Found by failing unit tests mailcommon-filter-filteractiondecrypttest & mailcommon-filter-filteractionencrypttest --- src/util/cryptoutils.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/util/cryptoutils.cpp b/src/util/cryptoutils.cpp index e8169a7..9ee39f5 100644 --- a/src/util/cryptoutils.cpp +++ b/src/util/cryptoutils.cpp @@ -166,9 +166,17 @@ KMime::Message::Ptr CryptoUtils::assembleMessage(const KMime::Message::Ptr &orig out->setBody(const_cast(newContent)->encodedBody()); out->parse(); + // remove default explicit content headers added by KMime::Content::parse() + QVector headers = out->headers(); + for (const auto hdr : std::as_const(headers)) { + if (isContentHeader(hdr)) { + out->removeHeader(hdr->type()); + } + } + // Copy over headers from the original message, except for CT, CTE and CD // headers, we want to preserve those from the new content - QVector headers = orig->headers(); + headers = orig->headers(); for (const auto hdr : std::as_const(headers)) { if (isContentHeader(hdr)) { continue;