diff options
Diffstat (limited to 'framework/src')
-rw-r--r-- | framework/src/domain/mime/crypto.cpp | 2 | ||||
-rw-r--r-- | framework/src/domain/mime/tests/mailtemplatetest.cpp | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/framework/src/domain/mime/crypto.cpp b/framework/src/domain/mime/crypto.cpp index 1b121931..863c4b38 100644 --- a/framework/src/domain/mime/crypto.cpp +++ b/framework/src/domain/mime/crypto.cpp | |||
@@ -97,6 +97,8 @@ static std::pair<gpgme_error_t, gpgme_ctx_t> createForProtocol(CryptoProtocol pr | |||
97 | Q_ASSERT(false); | 97 | Q_ASSERT(false); |
98 | return std::make_pair(1, nullptr); | 98 | return std::make_pair(1, nullptr); |
99 | } | 99 | } |
100 | //We want the output to always be ASCII armored | ||
101 | gpgme_set_armor(ctx, 1); | ||
100 | return std::make_pair(GPG_ERR_NO_ERROR, ctx); | 102 | return std::make_pair(GPG_ERR_NO_ERROR, ctx); |
101 | } | 103 | } |
102 | 104 | ||
diff --git a/framework/src/domain/mime/tests/mailtemplatetest.cpp b/framework/src/domain/mime/tests/mailtemplatetest.cpp index 20ea8c5e..508af9aa 100644 --- a/framework/src/domain/mime/tests/mailtemplatetest.cpp +++ b/framework/src/domain/mime/tests/mailtemplatetest.cpp | |||
@@ -63,6 +63,17 @@ static QString unquote(const QString &s) | |||
63 | class MailTemplateTest : public QObject | 63 | class MailTemplateTest : public QObject |
64 | { | 64 | { |
65 | Q_OBJECT | 65 | Q_OBJECT |
66 | |||
67 | bool validate(KMime::Message::Ptr msg) | ||
68 | { | ||
69 | const auto data = msg->encodedContent(); | ||
70 | //IMAP compat: The ASCII NUL character, %x00, MUST NOT be used at any time. | ||
71 | if (data.contains('\0')) { | ||
72 | return false; | ||
73 | } | ||
74 | return true; | ||
75 | } | ||
76 | |||
66 | private slots: | 77 | private slots: |
67 | 78 | ||
68 | void initTestCase() | 79 | void initTestCase() |
@@ -268,6 +279,7 @@ private slots: | |||
268 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments); | 279 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments); |
269 | 280 | ||
270 | QVERIFY(result); | 281 | QVERIFY(result); |
282 | QVERIFY(validate(result)); | ||
271 | QCOMPARE(result->subject()->asUnicodeString(), subject); | 283 | QCOMPARE(result->subject()->asUnicodeString(), subject); |
272 | QCOMPARE(result->body(), body.toUtf8()); | 284 | QCOMPARE(result->body(), body.toUtf8()); |
273 | QVERIFY(result->date(false)->dateTime().isValid()); | 285 | QVERIFY(result->date(false)->dateTime().isValid()); |
@@ -289,6 +301,7 @@ private slots: | |||
289 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, true, attachments); | 301 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, true, attachments); |
290 | 302 | ||
291 | QVERIFY(result); | 303 | QVERIFY(result); |
304 | QVERIFY(validate(result)); | ||
292 | QCOMPARE(result->subject()->asUnicodeString(), subject); | 305 | QCOMPARE(result->subject()->asUnicodeString(), subject); |
293 | QVERIFY(result->date(false)->dateTime().isValid()); | 306 | QVERIFY(result->date(false)->dateTime().isValid()); |
294 | QVERIFY(result->contentType()->isMimeType("multipart/alternative")); | 307 | QVERIFY(result->contentType()->isMimeType("multipart/alternative")); |
@@ -311,6 +324,7 @@ private slots: | |||
311 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments); | 324 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments); |
312 | 325 | ||
313 | QVERIFY(result); | 326 | QVERIFY(result); |
327 | QVERIFY(validate(result)); | ||
314 | QCOMPARE(result->subject()->asUnicodeString(), subject); | 328 | QCOMPARE(result->subject()->asUnicodeString(), subject); |
315 | QVERIFY(result->contentType()->isMimeType("multipart/mixed")); | 329 | QVERIFY(result->contentType()->isMimeType("multipart/mixed")); |
316 | QVERIFY(result->date(false)->dateTime().isValid()); | 330 | QVERIFY(result->date(false)->dateTime().isValid()); |
@@ -335,6 +349,7 @@ private slots: | |||
335 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, true, attachments); | 349 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, true, attachments); |
336 | 350 | ||
337 | QVERIFY(result); | 351 | QVERIFY(result); |
352 | QVERIFY(validate(result)); | ||
338 | QCOMPARE(result->subject()->asUnicodeString(), subject); | 353 | QCOMPARE(result->subject()->asUnicodeString(), subject); |
339 | QVERIFY(result->contentType()->isMimeType("multipart/mixed")); | 354 | QVERIFY(result->contentType()->isMimeType("multipart/mixed")); |
340 | QVERIFY(result->date(false)->dateTime().isValid()); | 355 | QVERIFY(result->date(false)->dateTime().isValid()); |
@@ -360,6 +375,7 @@ private slots: | |||
360 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments, keys, {}, keys[0]); | 375 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments, keys, {}, keys[0]); |
361 | 376 | ||
362 | QVERIFY(result); | 377 | QVERIFY(result); |
378 | QVERIFY(validate(result)); | ||
363 | // qWarning() << "---------------------------------"; | 379 | // qWarning() << "---------------------------------"; |
364 | // qWarning().noquote() << result->encodedContent(); | 380 | // qWarning().noquote() << result->encodedContent(); |
365 | // qWarning() << "---------------------------------"; | 381 | // qWarning() << "---------------------------------"; |
@@ -401,6 +417,7 @@ private slots: | |||
401 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments, Crypto::findKeys({}, true, false)); | 417 | auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments, Crypto::findKeys({}, true, false)); |
402 | 418 | ||
403 | QVERIFY(result); | 419 | QVERIFY(result); |
420 | QVERIFY(validate(result)); | ||
404 | QCOMPARE(result->subject()->asUnicodeString(), subject); | 421 | QCOMPARE(result->subject()->asUnicodeString(), subject); |
405 | QVERIFY(result->date(false)->dateTime().isValid()); | 422 | QVERIFY(result->date(false)->dateTime().isValid()); |
406 | 423 | ||