diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-06-29 16:43:20 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-06-29 16:43:20 +0200 |
commit | b390d0e43a803861268d68deefca03b09d6731f3 (patch) | |
tree | 562d1dd422734d01526f5d9bc677abc39f0af806 /framework/src/domain/mime/mimetreeparser | |
parent | 904c8e08fd3c73174a8b4aadbc45a6895600d2cc (diff) | |
download | kube-b390d0e43a803861268d68deefca03b09d6731f3.tar.gz kube-b390d0e43a803861268d68deefca03b09d6731f3.zip |
Fixed apple html messages with attachments.
Diffstat (limited to 'framework/src/domain/mime/mimetreeparser')
-rw-r--r-- | framework/src/domain/mime/mimetreeparser/messagepart.cpp | 11 | ||||
-rw-r--r-- | framework/src/domain/mime/mimetreeparser/tests/mimetreeparsertest.cpp | 17 |
2 files changed, 28 insertions, 0 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/messagepart.cpp b/framework/src/domain/mime/mimetreeparser/messagepart.cpp index 4bed80da..1a1b2003 100644 --- a/framework/src/domain/mime/mimetreeparser/messagepart.cpp +++ b/framework/src/domain/mime/mimetreeparser/messagepart.cpp | |||
@@ -568,6 +568,17 @@ AlternativeMessagePart::AlternativeMessagePart(ObjectTreeParser *otp, KMime::Con | |||
568 | // immediate children of this multipart/alternative node. | 568 | // immediate children of this multipart/alternative node. |
569 | // In this case, the HTML node is a child of multipart/related. | 569 | // In this case, the HTML node is a child of multipart/related. |
570 | dataHtml = findTypeInDirectChilds(mNode, "multipart/related"); | 570 | dataHtml = findTypeInDirectChilds(mNode, "multipart/related"); |
571 | if (dataHtml) { | ||
572 | const auto parts = dataHtml->contents(); | ||
573 | for (int i = 0; i < parts.size(); i++) { | ||
574 | const auto p = parts.at(i); | ||
575 | if (i == 0 ) { | ||
576 | dataHtml = p; | ||
577 | } else if (KMime::isAttachment(p)) { | ||
578 | appendSubPart(MimeMessagePart::Ptr(new MimeMessagePart(otp, p, true))); | ||
579 | } | ||
580 | } | ||
581 | } | ||
571 | 582 | ||
572 | // Still not found? Stupid apple mail actually puts the attachments inside of the | 583 | // Still not found? Stupid apple mail actually puts the attachments inside of the |
573 | // multipart/alternative, which is wrong. Therefore we also have to look for multipart/mixed | 584 | // multipart/alternative, which is wrong. Therefore we also have to look for multipart/mixed |
diff --git a/framework/src/domain/mime/mimetreeparser/tests/mimetreeparsertest.cpp b/framework/src/domain/mime/mimetreeparser/tests/mimetreeparsertest.cpp index 97c79fe7..6b4280a9 100644 --- a/framework/src/domain/mime/mimetreeparser/tests/mimetreeparsertest.cpp +++ b/framework/src/domain/mime/mimetreeparser/tests/mimetreeparsertest.cpp | |||
@@ -401,6 +401,23 @@ private slots: | |||
401 | QCOMPARE(part->signatureState(), MimeTreeParser::KMMsgFullySigned); | 401 | QCOMPARE(part->signatureState(), MimeTreeParser::KMMsgFullySigned); |
402 | QCOMPARE(otp.plainTextContent(), QString::fromUtf8("test\n\n-- \nThis is a HTML signature.\n")); | 402 | QCOMPARE(otp.plainTextContent(), QString::fromUtf8("test\n\n-- \nThis is a HTML signature.\n")); |
403 | } | 403 | } |
404 | |||
405 | void testAppleHtmlWithAttachments() | ||
406 | { | ||
407 | MimeTreeParser::ObjectTreeParser otp; | ||
408 | otp.parseObjectTree(readMailFromFile("applehtmlwithattachments.mbox")); | ||
409 | otp.decryptParts(); | ||
410 | auto partList = otp.collectContentParts(); | ||
411 | QCOMPARE(partList.size(), 1); | ||
412 | auto part = partList[0].dynamicCast<MimeTreeParser::MessagePart>(); | ||
413 | QCOMPARE(part->encryptions().size(), 0); | ||
414 | QCOMPARE(part->signatures().size(), 0); | ||
415 | QCOMPARE(otp.plainTextContent(), QString::fromUtf8("Hi,\n\nThis is an HTML message with attachments.\n\nCheers,\nChristian")); | ||
416 | QCOMPARE(otp.htmlContent(), QString::fromUtf8("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=us-ascii\"></head><body style=\"word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;\" class=\"\"><meta http-equiv=\"Content-Type\" content=\"text/html; charset=us-ascii\" class=\"\"><div style=\"word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;\" class=\"\">Hi,<div class=\"\"><br class=\"\"></div><blockquote style=\"margin: 0 0 0 40px; border: none; padding: 0px;\" class=\"\"><div class=\"\">This is an <b class=\"\">HTML</b> message with attachments.</div></blockquote><div class=\"\"><br class=\"\"></div><div class=\"\">Cheers,</div><div class=\"\">Christian<img apple-inline=\"yes\" id=\"B9EE68A9-83CA-41CD-A3E4-E5BA301F797A\" class=\"\" src=\"cid:F5B62D1D-E4EC-4C59-AA5A-708525C2AC3C\"></div></div></body></html>")); | ||
417 | |||
418 | auto attachments = otp.collectAttachmentParts(); | ||
419 | QCOMPARE(attachments.size(), 1); | ||
420 | } | ||
404 | }; | 421 | }; |
405 | 422 | ||
406 | QTEST_GUILESS_MAIN(InterfaceTest) | 423 | QTEST_GUILESS_MAIN(InterfaceTest) |