diff options
Diffstat (limited to 'framework/domain/mimetreeparser')
12 files changed, 330 insertions, 92 deletions
diff --git a/framework/domain/mimetreeparser/interface.cpp b/framework/domain/mimetreeparser/interface.cpp index c239fcc0..e34ffda7 100644 --- a/framework/domain/mimetreeparser/interface.cpp +++ b/framework/domain/mimetreeparser/interface.cpp | |||
@@ -18,6 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "interface.h" | 20 | #include "interface.h" |
21 | #include "interface_p.h" | ||
21 | 22 | ||
22 | #include "stringhtmlwriter.h" | 23 | #include "stringhtmlwriter.h" |
23 | #include "objecttreesource.h" | 24 | #include "objecttreesource.h" |
@@ -28,7 +29,6 @@ | |||
28 | #include <MimeTreeParser/NodeHelper> | 29 | #include <MimeTreeParser/NodeHelper> |
29 | 30 | ||
30 | #include <QDebug> | 31 | #include <QDebug> |
31 | #include <QImage> | ||
32 | 32 | ||
33 | class PartPrivate | 33 | class PartPrivate |
34 | { | 34 | { |
@@ -164,34 +164,42 @@ public: | |||
164 | void fillFrom(MimeTreeParser::HtmlMessagePart::Ptr part); | 164 | void fillFrom(MimeTreeParser::HtmlMessagePart::Ptr part); |
165 | void fillFrom(MimeTreeParser::AlternativeMessagePart::Ptr part); | 165 | void fillFrom(MimeTreeParser::AlternativeMessagePart::Ptr part); |
166 | 166 | ||
167 | QVector<Content::Ptr> content() const; | 167 | QVector<Content::Ptr> content(ContentPart::Type ct) const; |
168 | 168 | ||
169 | ContentPart *q; | 169 | ContentPart *q; |
170 | 170 | ||
171 | ContentPart::Types types() const; | 171 | ContentPart::Types types() const; |
172 | 172 | ||
173 | private: | 173 | private: |
174 | QVector<Content::Ptr> mContent; | 174 | QMap<ContentPart::Type, QVector<Content::Ptr>> mContent; |
175 | ContentPart::Types mTypes; | 175 | ContentPart::Types mTypes; |
176 | }; | 176 | }; |
177 | 177 | ||
178 | void ContentPartPrivate::fillFrom(MimeTreeParser::TextMessagePart::Ptr part) | 178 | void ContentPartPrivate::fillFrom(MimeTreeParser::TextMessagePart::Ptr part) |
179 | { | 179 | { |
180 | qDebug() << "jepp"; | ||
180 | mTypes = ContentPart::PlainText; | 181 | mTypes = ContentPart::PlainText; |
181 | foreach (const auto &mp, part->subParts()) { | 182 | foreach (const auto &mp, part->subParts()) { |
182 | auto content = std::make_shared<Content>(mp->text().toLocal8Bit(), q); | 183 | auto content = std::make_shared<Content>(mp->text().toLocal8Bit(), q); |
183 | mContent.append(content); | 184 | mContent[ContentPart::PlainText].append(content); |
184 | } | 185 | } |
185 | } | 186 | } |
186 | 187 | ||
187 | void ContentPartPrivate::fillFrom(MimeTreeParser::HtmlMessagePart::Ptr part) | 188 | void ContentPartPrivate::fillFrom(MimeTreeParser::HtmlMessagePart::Ptr part) |
188 | { | 189 | { |
189 | mTypes = ContentPart::Html; | 190 | mTypes = ContentPart::Html; |
191 | auto content = std::make_shared<Content>(part->text().toLocal8Bit(), q); | ||
192 | mContent[ContentPart::Html].append(content); | ||
190 | } | 193 | } |
191 | 194 | ||
192 | void ContentPartPrivate::fillFrom(MimeTreeParser::AlternativeMessagePart::Ptr part) | 195 | void ContentPartPrivate::fillFrom(MimeTreeParser::AlternativeMessagePart::Ptr part) |
193 | { | 196 | { |
194 | mTypes = ContentPart::Html | ContentPart::PlainText; | 197 | mTypes = ContentPart::Html | ContentPart::PlainText; |
198 | |||
199 | auto content = std::make_shared<Content>(part->htmlContent().toLocal8Bit(), q); | ||
200 | mContent[ContentPart::Html].append(content); | ||
201 | content = std::make_shared<Content>(part->plaintextContent().toLocal8Bit(), q); | ||
202 | mContent[ContentPart::PlainText].append(content); | ||
195 | } | 203 | } |
196 | 204 | ||
197 | ContentPart::Types ContentPartPrivate::types() const | 205 | ContentPart::Types ContentPartPrivate::types() const |
@@ -199,14 +207,14 @@ ContentPart::Types ContentPartPrivate::types() const | |||
199 | return mTypes; | 207 | return mTypes; |
200 | } | 208 | } |
201 | 209 | ||
202 | QVector<Content::Ptr> ContentPartPrivate::content() const | 210 | QVector<Content::Ptr> ContentPartPrivate::content(ContentPart::Type ct) const |
203 | { | 211 | { |
204 | return mContent; | 212 | return mContent[ct]; |
205 | } | 213 | } |
206 | 214 | ||
207 | QVector<Content::Ptr> ContentPart::content(ContentPart::Type ct) const | 215 | QVector<Content::Ptr> ContentPart::content(ContentPart::Type ct) const |
208 | { | 216 | { |
209 | return d->content(); | 217 | return d->content(ct); |
210 | } | 218 | } |
211 | 219 | ||
212 | 220 | ||
@@ -258,24 +266,6 @@ QByteArray AttachmentPart::type() const | |||
258 | return "AttachmentPart"; | 266 | return "AttachmentPart"; |
259 | } | 267 | } |
260 | 268 | ||
261 | class ParserPrivate | ||
262 | { | ||
263 | public: | ||
264 | ParserPrivate(Parser *parser); | ||
265 | |||
266 | void setMessage(const QByteArray &mimeMessage); | ||
267 | void createTree(const MimeTreeParser::MessagePart::Ptr& start, const Part::Ptr& tree); | ||
268 | |||
269 | Part::Ptr mTree; | ||
270 | private: | ||
271 | Parser *q; | ||
272 | |||
273 | MimeTreeParser::MessagePart::Ptr mPartTree; | ||
274 | std::shared_ptr<MimeTreeParser::NodeHelper> mNodeHelper; | ||
275 | QString mHtml; | ||
276 | QMap<QByteArray, QUrl> mEmbeddedPartMap; | ||
277 | }; | ||
278 | |||
279 | ParserPrivate::ParserPrivate(Parser* parser) | 269 | ParserPrivate::ParserPrivate(Parser* parser) |
280 | : q(parser) | 270 | : q(parser) |
281 | , mNodeHelper(std::make_shared<MimeTreeParser::NodeHelper>()) | 271 | , mNodeHelper(std::make_shared<MimeTreeParser::NodeHelper>()) |
@@ -292,7 +282,6 @@ void ParserPrivate::setMessage(const QByteArray& mimeMessage) | |||
292 | 282 | ||
293 | // render the mail | 283 | // render the mail |
294 | StringHtmlWriter htmlWriter; | 284 | StringHtmlWriter htmlWriter; |
295 | QImage paintDevice; | ||
296 | ObjectTreeSource source(&htmlWriter); | 285 | ObjectTreeSource source(&htmlWriter); |
297 | MimeTreeParser::ObjectTreeParser otp(&source, mNodeHelper.get()); | 286 | MimeTreeParser::ObjectTreeParser otp(&source, mNodeHelper.get()); |
298 | 287 | ||
@@ -315,7 +304,11 @@ void ParserPrivate::createTree(const MimeTreeParser::MessagePart::Ptr &start, co | |||
315 | const auto alternative = mp.dynamicCast<MimeTreeParser::AlternativeMessagePart>(); | 304 | const auto alternative = mp.dynamicCast<MimeTreeParser::AlternativeMessagePart>(); |
316 | const auto html = mp.dynamicCast<MimeTreeParser::HtmlMessagePart>(); | 305 | const auto html = mp.dynamicCast<MimeTreeParser::HtmlMessagePart>(); |
317 | const auto attachment = mp.dynamicCast<MimeTreeParser::AttachmentMessagePart>(); | 306 | const auto attachment = mp.dynamicCast<MimeTreeParser::AttachmentMessagePart>(); |
318 | if (text) { | 307 | if (attachment) { |
308 | auto part = std::make_shared<AttachmentPart>(); | ||
309 | part->d->fillFrom(attachment); | ||
310 | mTree->d->appendSubPart(part); | ||
311 | } else if (text) { | ||
319 | auto part = std::make_shared<ContentPart>(); | 312 | auto part = std::make_shared<ContentPart>(); |
320 | part->d->fillFrom(text); | 313 | part->d->fillFrom(text); |
321 | mTree->d->appendSubPart(part); | 314 | mTree->d->appendSubPart(part); |
@@ -327,10 +320,6 @@ void ParserPrivate::createTree(const MimeTreeParser::MessagePart::Ptr &start, co | |||
327 | auto part = std::make_shared<ContentPart>(); | 320 | auto part = std::make_shared<ContentPart>(); |
328 | part->d->fillFrom(html); | 321 | part->d->fillFrom(html); |
329 | mTree->d->appendSubPart(part); | 322 | mTree->d->appendSubPart(part); |
330 | } else if (attachment) { | ||
331 | auto part = std::make_shared<AttachmentPart>(); | ||
332 | part->d->fillFrom(attachment); | ||
333 | mTree->d->appendSubPart(part); | ||
334 | } else { | 323 | } else { |
335 | createTree(m, tree); | 324 | createTree(m, tree); |
336 | } | 325 | } |
@@ -349,7 +338,7 @@ Parser::~Parser() | |||
349 | 338 | ||
350 | ContentPart::Ptr Parser::collectContentPart(const Part::Ptr &start) const | 339 | ContentPart::Ptr Parser::collectContentPart(const Part::Ptr &start) const |
351 | { | 340 | { |
352 | const auto ret = collect<ContentPart>(start, [](const Part::Ptr &p){return p->type() == "ContentPart";}, [](const ContentPart::Ptr &p){return true;}); | 341 | const auto ret = collect<ContentPart>(start, [](const Part::Ptr &p){return p->type() == "ContentPart";}, [](const ContentPart::Ptr &p){return true;}); |
353 | if (ret.size() > 0) { | 342 | if (ret.size() > 0) { |
354 | return ret[0]; | 343 | return ret[0]; |
355 | }; | 344 | }; |
diff --git a/framework/domain/mimetreeparser/interface.h b/framework/domain/mimetreeparser/interface.h index 8a0047ff..0aef7fd0 100644 --- a/framework/domain/mimetreeparser/interface.h +++ b/framework/domain/mimetreeparser/interface.h | |||
@@ -187,6 +187,7 @@ public: | |||
187 | 187 | ||
188 | private: | 188 | private: |
189 | std::unique_ptr<AttachmentPartPrivate> d; | 189 | std::unique_ptr<AttachmentPartPrivate> d; |
190 | |||
190 | friend class ParserPrivate; | 191 | friend class ParserPrivate; |
191 | }; | 192 | }; |
192 | 193 | ||
@@ -325,5 +326,7 @@ signals: | |||
325 | 326 | ||
326 | private: | 327 | private: |
327 | std::unique_ptr<ParserPrivate> d; | 328 | std::unique_ptr<ParserPrivate> d; |
329 | |||
330 | friend class InterfaceTest; | ||
328 | }; | 331 | }; |
329 | 332 | ||
diff --git a/framework/domain/mimetreeparser/interface_p.h b/framework/domain/mimetreeparser/interface_p.h new file mode 100644 index 00000000..f83af6eb --- /dev/null +++ b/framework/domain/mimetreeparser/interface_p.h | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Sandro Knauß <knauss@kolabsystems.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include "interface.h" | ||
23 | |||
24 | #include <QSharedPointer> | ||
25 | #include <QMap> | ||
26 | |||
27 | namespace MimeTreeParser | ||
28 | { | ||
29 | class MessagePart; | ||
30 | class NodeHelper; | ||
31 | typedef QSharedPointer<MessagePart> MessagePartPtr; | ||
32 | } | ||
33 | |||
34 | class ParserPrivate | ||
35 | { | ||
36 | public: | ||
37 | ParserPrivate(Parser *parser); | ||
38 | |||
39 | void setMessage(const QByteArray &mimeMessage); | ||
40 | void createTree(const MimeTreeParser::MessagePartPtr& start, const Part::Ptr& tree); | ||
41 | |||
42 | Part::Ptr mTree; | ||
43 | private: | ||
44 | Parser *q; | ||
45 | |||
46 | MimeTreeParser::MessagePartPtr mPartTree; | ||
47 | std::shared_ptr<MimeTreeParser::NodeHelper> mNodeHelper; | ||
48 | QString mHtml; | ||
49 | QMap<QByteArray, QUrl> mEmbeddedPartMap; | ||
50 | }; \ No newline at end of file | ||
diff --git a/framework/domain/mimetreeparser/tests/data/alternative.mbox b/framework/domain/mimetreeparser/tests/data/alternative.mbox index a2c58591..6522c34b 100644 --- a/framework/domain/mimetreeparser/tests/data/alternative.mbox +++ b/framework/domain/mimetreeparser/tests/data/alternative.mbox | |||
@@ -17,18 +17,12 @@ ur newsletter properly. | |||
17 | Please visit this link to view the newsletter on our website: http://www.go= | 17 | Please visit this link to view the newsletter on our website: http://www.go= |
18 | g.com/newsletter/ | 18 | g.com/newsletter/ |
19 | 19 | ||
20 | =2D GOG.com Team | ||
21 | |||
22 | 20 | ||
23 | ------=_Part_12345678_12345678 | 21 | ------=_Part_12345678_12345678 |
24 | Content-Transfer-Encoding: 7Bit | 22 | Content-Transfer-Encoding: 7Bit |
25 | Content-Type: text/html; charset="windows-1252" | 23 | Content-Type: text/html; charset="windows-1252" |
26 | 24 | ||
27 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> | 25 | <html><body><p><span>HTML</span> text</p></body></html> |
28 | <html><head><meta name="qrichtext" content="1" /><style type="text/css"> | ||
29 | p, li { white-space: pre-wrap; } | ||
30 | </style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> | ||
31 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Some <span style=" font-weight:600;">HTML</span> text</p></body></html> | ||
32 | 26 | ||
33 | 27 | ||
34 | ------=_Part_12345678_12345678-- | 28 | ------=_Part_12345678_12345678-- |
diff --git a/framework/domain/mimetreeparser/tests/data/html.mbox b/framework/domain/mimetreeparser/tests/data/html.mbox index d476a8d4..bf5c685d 100644 --- a/framework/domain/mimetreeparser/tests/data/html.mbox +++ b/framework/domain/mimetreeparser/tests/data/html.mbox | |||
@@ -12,8 +12,4 @@ MIME-Version: 1.0 | |||
12 | Content-Transfer-Encoding: 7Bit | 12 | Content-Transfer-Encoding: 7Bit |
13 | Content-Type: text/html; charset="windows-1252" | 13 | Content-Type: text/html; charset="windows-1252" |
14 | 14 | ||
15 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> | 15 | <html><body><p><span>HTML</span> text</p></body></html> \ No newline at end of file |
16 | <html><head><meta name="qrichtext" content="1" /><style type="text/css"> | ||
17 | p, li { white-space: pre-wrap; } | ||
18 | </style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> | ||
19 | <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Some <span style=" font-weight:600;">HTML</span> text</p></body></html> | ||
diff --git a/framework/domain/mimetreeparser/tests/data/htmlonly.mbox b/framework/domain/mimetreeparser/tests/data/htmlonly.mbox deleted file mode 100644 index e45b1c4d..00000000 --- a/framework/domain/mimetreeparser/tests/data/htmlonly.mbox +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | From foo@example.com Thu, 26 May 2011 01:16:54 +0100 | ||
2 | From: Thomas McGuire <foo@example.com> | ||
3 | Subject: HTML test | ||
4 | Date: Thu, 26 May 2011 01:16:54 +0100 | ||
5 | Message-ID: <1501334.pROlBb7MZF@herrwackelpudding.localhost> | ||
6 | X-KMail-Transport: GMX | ||
7 | X-KMail-Fcc: 28 | ||
8 | X-KMail-Drafts: 7 | ||
9 | X-KMail-Templates: 9 | ||
10 | User-Agent: KMail/4.6 beta5 (Linux/2.6.34.7-0.7-desktop; KDE/4.6.41; x86_64; git-0269848; 2011-04-19) | ||
11 | MIME-Version: 1.0 | ||
12 | Content-Type: text/html | ||
13 | Content-Transfer-Encoding: 7Bit | ||
14 | |||
15 | <html> | ||
16 | <head> | ||
17 | </head> | ||
18 | <body> | ||
19 | <b>SOME</b> HTML text. | ||
20 | </body> | ||
21 | </html> | ||
diff --git a/framework/domain/mimetreeparser/tests/data/htmlonlyexternal.mbox b/framework/domain/mimetreeparser/tests/data/htmlonlyexternal.mbox deleted file mode 100644 index 4eb3e2c3..00000000 --- a/framework/domain/mimetreeparser/tests/data/htmlonlyexternal.mbox +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | From foo@example.com Thu, 26 May 2011 01:16:54 +0100 | ||
2 | From: Thomas McGuire <foo@example.com> | ||
3 | Subject: HTML test | ||
4 | Date: Thu, 26 May 2011 01:16:54 +0100 | ||
5 | Message-ID: <1501334.pROlBb7MZF@herrwackelpudding.localhost> | ||
6 | X-KMail-Transport: GMX | ||
7 | X-KMail-Fcc: 28 | ||
8 | X-KMail-Drafts: 7 | ||
9 | X-KMail-Templates: 9 | ||
10 | User-Agent: KMail/4.6 beta5 (Linux/2.6.34.7-0.7-desktop; KDE/4.6.41; x86_64; git-0269848; 2011-04-19) | ||
11 | MIME-Version: 1.0 | ||
12 | Content-Type: text/html | ||
13 | Content-Transfer-Encoding: 7Bit | ||
14 | |||
15 | <html> | ||
16 | <head> | ||
17 | </head> | ||
18 | <body> | ||
19 | <b>SOME</b> HTML text. <img src="http://example.org/test.img" > | ||
20 | </body> | ||
21 | </html> | ||
diff --git a/framework/domain/mimetreeparser/tests/data/openpgp-encrypted-attachment-and-non-encrypted-attachment.mbox b/framework/domain/mimetreeparser/tests/data/openpgp-encrypted-attachment-and-non-encrypted-attachment.mbox new file mode 100644 index 00000000..2d9726ea --- /dev/null +++ b/framework/domain/mimetreeparser/tests/data/openpgp-encrypted-attachment-and-non-encrypted-attachment.mbox | |||
@@ -0,0 +1,115 @@ | |||
1 | From test@kolab.org Fri May 01 15:12:47 2015 | ||
2 | From: testkey <test@kolab.org> | ||
3 | To: you@you.com | ||
4 | Subject: enc & non enc attachment | ||
5 | Date: Fri, 01 May 2015 17:12:47 +0200 | ||
6 | Message-ID: <13897561.XENKdJMSlR@tabin.local> | ||
7 | X-KMail-Identity: 1197256126 | ||
8 | User-Agent: KMail/4.13.0.1 (Linux/3.19.1-towo.1-siduction-amd64; KDE/4.14.2; x86_64; git-cd33034; 2015-04-11) | ||
9 | MIME-Version: 1.0 | ||
10 | Content-Type: multipart/mixed; boundary="nextPart1939768.sIoLGH0PD8" | ||
11 | Content-Transfer-Encoding: 7Bit | ||
12 | |||
13 | This is a multi-part message in MIME format. | ||
14 | |||
15 | --nextPart1939768.sIoLGH0PD8 | ||
16 | Content-Type: multipart/encrypted; boundary="nextPart2814166.CHKktCGlQ3"; protocol="application/pgp-encrypted" | ||
17 | |||
18 | |||
19 | --nextPart2814166.CHKktCGlQ3 | ||
20 | Content-Type: application/pgp-encrypted | ||
21 | Content-Disposition: attachment | ||
22 | Content-Transfer-Encoding: 7Bit | ||
23 | |||
24 | Version: 1 | ||
25 | --nextPart2814166.CHKktCGlQ3 | ||
26 | Content-Type: application/octet-stream | ||
27 | Content-Disposition: inline; filename="msg.asc" | ||
28 | Content-Transfer-Encoding: 7Bit | ||
29 | |||
30 | -----BEGIN PGP MESSAGE----- | ||
31 | Version: GnuPG v2 | ||
32 | |||
33 | hIwDGJlthTT7oq0BA/9cXFQ6mN9Vxnc2B9M10odS3/6z1tsIY9oJdsiOjpfxqapX | ||
34 | P7nOzR/jNWdFQanXoG1SjAcY2FeZEN0c3SkxEM6R5QVF1vMh/Xsni1clI+peZyVT | ||
35 | Z4OSU74YCfYLg+cgDnPCF3kyNPVe6Z1pnfWOCZNCG3rpApw6UVLN63ScWC6eQIUB | ||
36 | DAMMzkNap8zaOwEIANKHn1svvj+hBOIZYf8R+q2Bw7cd4xEChiJ7uQLnD98j0Fh1 | ||
37 | 85v7/8JbZx6rEDDenPp1mCciDodb0aCmi0XLuzJz2ANGTVflfq+ZA+v1pwLksWCs | ||
38 | 0YcHLEjOJzjr3KKmvu6wqnun5J2yV69K3OW3qTTGhNvcYZulqQ617pPa48+sFCgh | ||
39 | nM8TMAD0ElVEwmMtrS3AWoJz52Af+R3YzpAnX8NzV317/JG+b6e2ksl3tR7TWp1q | ||
40 | 2FOqC1sXAxuv+DIz4GgRfaK1+xYr2ckkg+H/3HJqa5LmJ7rGCyv+Epfp9u+OvdBG | ||
41 | PBvuCtO3tm0crmnttMw57Gy35BKutRf/8MpBj/nS6QFX0t7XOLeL4Me7/a2H20wz | ||
42 | HZsuRGDXMCh0lL0FYCBAwdbbYvvy0gz/5iaNvoADtaIu+VtbFNrTUN0SwuL+AIFS | ||
43 | +WIiaSbFt4Ng3t9YmqL6pqB7fjxI10S+PK0s7ABqe4pgbzUWWt1yzBcxfk8l/47Q | ||
44 | JrlvcE7HuDOhNOHfZIgUP2Dbeu+pVvHIJbmLsNWpl4s+nHhoxc9HrVhYG/MTZtQ3 | ||
45 | kkUWviegO6mwEZjQvgBxjWib7090sCxkO847b8A93mfQNHnuy2ZEEJ+9xyk7nIWs | ||
46 | 4RsiNR8pYc/SMvdocyAvQMH/qSvmn/IFJ+jHhtT8UJlXJ0bHvXTHjHMqBp6fP69z | ||
47 | Jh1ERadWQdMaTkzQ+asl+kl/x3p6RZP8MEVbZIl/3pcV+xiFCYcFu2TETKMtbW+b | ||
48 | NYOlrltFxFDvyu3WeNNp0g9k0nFpD/T1OXHRBRcbUDWE4QF6NWTm6NO9wy2UYHCi | ||
49 | 7QTSecBWgMaw7cUdwvnW6chIVoov1pm69BI9D0PoV76zCI7KzpiDsTFxdilKwbQf | ||
50 | K/PDnv9Adx3ERh0/F8llBHrj2UGsRs4aHSEBDBJIHDCp8+lqtsRcINQBKEU3qIjt | ||
51 | wf5vizdaVIgQnsD2z8QmBQ7QCCipI0ur6GKl+YWDDOSDLDUs9dK4A6xo/4Q0bsnI | ||
52 | rH63ti5HslGq6uArfFkewH2MWff/8Li3uGEqzpK5NhP5UpbArelK+QaQQP5SdsmW | ||
53 | XFwUqDS4QTCKNJXw/5SQMl8UE10l2Xaav3TkiOYTcBcvPNDovYgnMyRff/tTeFa8 | ||
54 | 83STkvpGtkULkCntp22fydv5rg6DZ7eJrYfC2oZXdM87hHhUALUO6Y/VtVmNdNYw | ||
55 | F3Uim4PDuLIKt+mFqRtFqnWm+5X/AslC31qLkjH+Fbb83TY+mC9gbIn7CZGJRCjn | ||
56 | zzzMX2h15V/VHzNUgx9V/h28T0/z25FxoozZiJxpmhOtqoxMHp+y6nXXfMoIAD1D | ||
57 | 963Pc7u1HS0ny54A7bqc6KKd4W9IF7HkXn3SoBwCyn0IOPoKQTDD8mW3lbBI6+h9 | ||
58 | vP+MAQpfD8s+3VZ9r7OKYCVmUv47ViTRlf428Co6WT7rTHjGM09tqz826fTOXA== | ||
59 | =6Eu9 | ||
60 | -----END PGP MESSAGE----- | ||
61 | |||
62 | --nextPart2814166.CHKktCGlQ3-- | ||
63 | |||
64 | --nextPart1939768.sIoLGH0PD8 | ||
65 | Content-Disposition: attachment; filename="image.png" | ||
66 | Content-Transfer-Encoding: base64 | ||
67 | Content-Type: image/png; name="image.png" | ||
68 | |||
69 | iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAlwSFlzAAAb | ||
70 | rwAAG68BXhqRHAAAAAd0SU1FB9gHFg8aNG8uqeIAAAAGYktHRAD/AP8A/6C9p5MAAAkqSURBVHja | ||
71 | 5VV7cFTVGf/OPefeu3fv3t1NdhMSCHkKASEpyEsaGwalWEWntLV1Wu0fdOxAx9Iq0xntAwac6ehY | ||
72 | p+rwKLbjjLRFh9JadURKRGgFQTTECCYQE9nNgzzYZDe7m33d1+l3tpOOU61T2tF/+s1s7pzn9/t+ | ||
73 | v993Av/3QT6FO6WdO/d+M55Il8rMOdrT0x3Zt++3+c8EgM/nozseeviJiYmpe1zOQdM8BOOCIku/ | ||
74 | lIj1VrQ/0r9n9+78xwLgeAA3w4fHXV1d5Omnn6aapumlJSVVqalUJJvJZRdcu0RSfZQsaW7mjfPm | ||
75 | cbF9+/btEIlEaq6Z03whXyhIjDFuGIZEKSP5fMFRVcVNT2Vf0jzsmMxYGtel9rff/vM/M8bjcZpM | ||
76 | Jp1XX32VNDc3e7ovRP3JyZGVNdXVd1FGGwKBQEM8njiWTKV36IHgEACwibGx62LjU/cBd01Zljoc | ||
77 | p9DHmLbHsmyK1UuKooJt24IMcLE+y3L45eEYLS8LgWH4YXR0bAPZtGmTVFvfoBZMEzKpFKmqqmqp | ||
78 | qane4DhOteH3L1FkWZVlGSzLAtd1Oe4773C4LxoZvDWXh82OY2MtwAuFvCvSyDIFXdelYDDIvF4d | ||
79 | xPzA0AgXFStMcWPxBPGoKvXpPh6JDG5hK1Zcv1H36Xc6tsMs21EMQ69CLSts2wGkDygTyW2CP8gX | ||
80 | TKLIyvx0OrdDUXyLKXVUkdSne4QKtFAwuWmabjAYkDyqAgG/jziORh1EKaonkkQt2yRZRC5JHEGn | ||
81 | L7OKyopNqqo2IbWQjqWgLOwFBFKsuGDa4PVyIssMk1sCACCjimXbrbquYKW41zJJOpXkeARyeZNQ | ||
82 | SUKwHEqCKnBuAybkZeFSmssVSDKdhlBpCRgIcnQsdvKPB19sY4rMNIaH0BhQUVHKvXgpIiQF0wK/ | ||
83 | 4QORnOEayoDzOSBMXK4BSgpeTcMECqiqTDKZHDKmct3LCI55Kp0mQgK/3yDYkgIc3kNhfHzCkRk9 | ||
84 | p6nk+yPD3SmWzeZiKNkciUrg2g5BjQWdSBchiEvQjzoWAFkUYPDrCjBFUEJ8AhSIRyl2jcfjEL9h | ||
85 | AFJODL8B6H7IZrNIt2g3B1mysShdQhmbT58+ExRdx3L5/PNomGU4kJkuA9ILYn+JP4CXOoDUoWO9 | ||
86 | IBhCSBCLTYCK+rqOg8CKvY6JPQhGxjkX1zyAdwrgAhTKWBDmxTUTC7Tcy5dHBiilL7cdaTsNGAwP | ||
87 | 7o32D4Q9HnWTrvsCiqIgdWgqDkJfkKgDU1MZcBGMhbKgj2B0LIle8eNhgiBsoMwFEY7rQDqVwlo5 | ||
88 | esUE/AAR81gUYIUT8UR2//4/rK+pLjs3MhIFEVJN9WwXK2oM+P1BREpQO0hjwkw+BzJWY1oOXB5L | ||
89 | w9DIOGTQvYS4UFqigR9ZwUqEXFghVop059AjonqcAIZrqCKg31AS3OU66Adf4sabWqKvvHIYpoNh | ||
90 | y+Vj4xMHVEW93eUuo0izhT4oRbcSIoALbRle4AVVkfBup6g9thwCzRX1VRQmdMeqLVETEIkW2ZNx | ||
91 | H8oqzqAfXCGJEQ6XBQEgNQ2A7tq1C1a1tvaattOOrVFOqVSLCQhqU6QPx+DTsOU0GavLYUV20Qv4 | ||
92 | rEIymYNQuB48Wkg8QTA0NIQeYKB6NGTgH90jIcJEMikAi1dRRo9NLV583ek33jjpFAGIPw8++IAj | ||
93 | e9SIRGm5wliraVosnTWLmmemUugBkTiPSS3AtgV8VQA9A8LxdfULYXBoEKv2wMhIn2BHGFR0DZ6d | ||
94 | glQ6hUDT6A/RWVSSmfx5DjxRV1vzVkdHBzDAWLNmDezc+aQVqqz5dSY52Z63nLn9A33lI9myLXNL | ||
95 | xv0Fq3gWutMN0BToxcso+AN+cKmOXI5A9P12mKDzYNXcZXDq1F+h+IboFgzb1VAhDULeJpxwC19G | ||
96 | g/uMgOXVfXW1tbWCYM6mtdi8+YfiM4m/Y1UrHzkergyXz/3czImCnRjuHiW3qxpPqGFPy6SpHJC9 | ||
97 | IR+Sm+2N8i/dcMOMZdGeshcrS/S58+c3zU2Z8oVD50cbVfP8M4pGkymoUxLxsUzOVhtmQ+5432Rg | ||
98 | oj6QOLFj28/caQk+EjMXraUV1eW+8dH06StQZnlnNbQefGTD92pWfu3I6TOT8oY7brv4hWUt3xiw | ||
99 | 2OrlDVVdRslsd2Fd469Q8sUB3c8uOW49SdHX1rbcePhoz3B7feuqlt5oZtBTv+ioSdXc7q3fHQaM | ||
100 | fwtg6Vd/dEvn8Qssnzg/0Ns56jRcO6Nw4d1Af+/RH0/cdv+O/fRK7KnmBXPWGsQeDPhK9oWC6hdd | ||
101 | R3pdUcg88Tx7U7Ej1y1qMjreGwjt/cnaF2YtvCXQe7bzxLkj+/sunT0Ry00OwHRI8DERLqeNmqGV | ||
102 | JZJVC6Yu7UxMOfLFlV9pWQcYp57/013rb1u9ua29b0Ch4bsl4tKLY5P1sgxNJzsHDj136KzS3NTk | ||
103 | 9mTNusPvXJLrbnjUe/b16FDfsZ/3xC8d4/HoCQ4Anwzg91vWPL7+3pvvDM806sTY4IVyMxfrojO3 | ||
104 | BVubbyJMhnVVM3y+l187/nChIJ2ZpSs9hMD4qC6t6x6+0gkAoRC33/Sb8RdmXj9nzvWraivhP47g | ||
105 | AyHxKb1mfWkRYHCjMb30nafeeWzerU9963w3L3/02c4f7D0y0NXTx3f3D/JTb7bzxpeODu55+PGT | ||
106 | yy5F+ZmeD/iSrh5efeJd/hGZP5GBux+6cysY3w7H+16IVy65V6trnn3P9JqVjQ3JuSsdHhWW6hIL | ||
107 | NuhyUpJgEF/ofSVBeLBuVtVjd3y55SHXhQ8UBht0DR4r98Fs+IRg/zrxlz2/2A7p5yYBY93Gu+4f | ||
108 | H5xojLwOxfjd/WufOHhQ/IcD7eYVC5YyCjFMfkVV4NpMFvpTachoZeDaNryLnliOczsUCv1XBWD8 | ||
109 | YjF5MWJ9kcT757qenR7vf4bDoqWwHCvUUfPNsQQMWSZAZTlsw7nxYQQTcuDrjgQuPn7z/D7YivNt | ||
110 | nPPfEDzwqcU75/j6SD/f8uG5vXs5dL7Hjb+d4gp8mnF8nAOabjcac+OBAxyuNiT4HyNwGZYgu0RW | ||
111 | IDt/Icz4zAC0tXE4183rQ6XwU9uBXgLQ5Teg7GIv1+EqgsF/GY4DtCQALZMp2ITttmqoHzpWr756 | ||
112 | o/0d59+Lh3Y1HHcAAAAASUVORK5CYII= | ||
113 | |||
114 | --nextPart1939768.sIoLGH0PD8-- | ||
115 | |||
diff --git a/framework/domain/mimetreeparser/tests/data/openpgp-inline-charset-encrypted.mbox b/framework/domain/mimetreeparser/tests/data/openpgp-inline-charset-encrypted.mbox new file mode 100644 index 00000000..8bd06910 --- /dev/null +++ b/framework/domain/mimetreeparser/tests/data/openpgp-inline-charset-encrypted.mbox | |||
@@ -0,0 +1,40 @@ | |||
1 | From test@example.com Thu, 17 Oct 2013 02:13:03 +0200 | ||
2 | Return-Path: <test@example.com> | ||
3 | Delivered-To: you@you.com | ||
4 | Received: from localhost (localhost [127.0.0.1]) | ||
5 | by test@example.com (Postfix) with ESMTP id B30D8120030 | ||
6 | for <you@you.com>; Thu, 17 Oct 2013 02:13:05 +0200 (CEST) | ||
7 | From: test <test@example.com> | ||
8 | To: you@you.com | ||
9 | Subject: charset | ||
10 | Date: Thu, 17 Oct 2013 02:13:03 +0200 | ||
11 | Message-ID: <4081645.yGjUJ4o4Se@example.local> | ||
12 | User-Agent: KMail/4.12 pre (Linux/3.11-4.towo-siduction-amd64; KDE/4.11.2; x86_64; git-f7f14e3; 2013-10-15) | ||
13 | MIME-Version: 1.0 | ||
14 | Content-Transfer-Encoding: 7Bit | ||
15 | Content-Type: text/plain; charset="ISO-8859-15" | ||
16 | |||
17 | -----BEGIN PGP MESSAGE----- | ||
18 | Version: GnuPG v2.0.22 (GNU/Linux) | ||
19 | |||
20 | hIwDGJlthTT7oq0BBACbaRZudMigMTetPZNRgkfEXv4QQowR1jborw0dcgKKqMQ1 | ||
21 | 6o67NkpxvmXKGJTfTVCLBX3nk6FKYo6NwlPCyU7X9X0DDk8hvaBdR9wGfrdm5YWX | ||
22 | GKOzcqJY1EypiMsspXeZvjzEW7O8I956c3vBb/2pM3xqYEK1kh8+d9bVH+cjf4UB | ||
23 | DAMMzkNap8zaOwEH/1rPShyYL8meJN+/GGgS8+Nf1BW5pSHdAPCg0dnX4QCLEx7u | ||
24 | GkBU6N4JGYayaCBofibOLacQPhYZdnR5Xb/Pvrx03GrzyzyDp0WyeI9nGNfkani7 | ||
25 | sCRWbzlMPsEvGEvJVnMLNRSk4xhPIWumL4APkw+Mgi6mf+Br8z0RhfnGwyMA53Mr | ||
26 | pG9VQKlq3v7/aaN40pMjAsxiytcHS515jXrb3Ko4pWbTlAr/eytOEfkLRJgSOpQT | ||
27 | BY7lWs+UQJqiG8Yn65vS9LMDNJgX9EOGx77Z4u9wvv4ZieOxzgbHGg5kYCoae7ba | ||
28 | hxZeNjYKscH+E6epbOxM/wlTdr4UTiiW9dMsH0zSwMUB891gToeXq+LDGEPTKVSX | ||
29 | tsJm4HS/kISJBwrCI4EUqWZML6xQ427NkZGmF2z/sD3kmL66GjspIKnb4zHmXacp | ||
30 | 84n2KrI9s7p6AnKnQjsxvB/4/lpXPCIY5GH7KjySEJiMsHECzeN1dJSL6keykBsx | ||
31 | DtmYDA+dhZ6UWbwzx/78+mjNREhyp/UiSAmLzlJh89OH/xelAPvKcIosYwz4cY9N | ||
32 | wjralTmL+Y0aHKeZJOeqPLaXADcPFiZrCNPCH65Ey5GEtDpjLpEbjVbykPV9+YkK | ||
33 | 7JKW6bwMraOl5zmAoR77PWMo3IoYb9q4GuqDr1V2ZGlb7eMH1gj1nfgfVintKC1X | ||
34 | 3jFfy7aK6LIQDVKEwbi0SxVXTKStuliVUy5oX4woDOxmTEotJf1QlKZpn5oF20UP | ||
35 | tumYrp0SPoP8Bo4EVRVaLupduI5cYce1q/kFj9Iho/wk56MoG9PxMMfsH7oKg3AA | ||
36 | CqQ6/kM4oJNdN5xIf1EH5HeaNFkDy1jlLznnhwVAZKPo/9ffpg== | ||
37 | =bPqu | ||
38 | -----END PGP MESSAGE----- | ||
39 | |||
40 | |||
diff --git a/framework/domain/mimetreeparser/tests/data/plaintext.mbox b/framework/domain/mimetreeparser/tests/data/plaintext.mbox index c2e00a35..d185b1c1 100644 --- a/framework/domain/mimetreeparser/tests/data/plaintext.mbox +++ b/framework/domain/mimetreeparser/tests/data/plaintext.mbox | |||
@@ -11,7 +11,3 @@ If you can see this text it means that your email client couldn't display o= | |||
11 | ur newsletter properly. | 11 | ur newsletter properly. |
12 | Please visit this link to view the newsletter on our website: http://www.go= | 12 | Please visit this link to view the newsletter on our website: http://www.go= |
13 | g.com/newsletter/ | 13 | g.com/newsletter/ |
14 | |||
15 | =2D GOG.com Team | ||
16 | |||
17 | |||
diff --git a/framework/domain/mimetreeparser/tests/data/smime-encrypted.mbox b/framework/domain/mimetreeparser/tests/data/smime-encrypted.mbox new file mode 100644 index 00000000..6b6d6a0d --- /dev/null +++ b/framework/domain/mimetreeparser/tests/data/smime-encrypted.mbox | |||
@@ -0,0 +1,22 @@ | |||
1 | From test@example.com Sat, 13 Apr 2013 01:54:30 +0200 | ||
2 | From: test <test@example.com> | ||
3 | To: you@you.com | ||
4 | Subject: test | ||
5 | Date: Sat, 13 Apr 2013 01:54:30 +0200 | ||
6 | Message-ID: <1576646.QQxzHWx8dA@tabin> | ||
7 | X-KMail-Identity: 505942601 | ||
8 | User-Agent: KMail/4.10.2 (Linux/3.9.0-rc4-experimental-amd64; KDE/4.10.60; x86_64; git-fc9b82c; 2013-04-11) | ||
9 | MIME-Version: 1.0 | ||
10 | Content-Type: application/pkcs7-mime; name="smime.p7m"; smime-type="enveloped-data" | ||
11 | Content-Transfer-Encoding: base64 | ||
12 | Content-Disposition: attachment; filename="smime.p7m" | ||
13 | |||
14 | MIAGCSqGSIb3DQEHA6CAMIACAQAxgfwwgfkCAQAwYjBVMQswCQYDVQQGEwJVUzENMAsGA1UECgwE | ||
15 | S0RBQjEWMBQGA1UEAwwNdW5pdHRlc3QgY2VydDEfMB0GCSqGSIb3DQEJARYQdGVzdEBleGFtcGxl | ||
16 | LmNvbQIJANNFIDoYY4XJMA0GCSqGSIb3DQEBAQUABIGAJwmmaOeidXUHSQGOf2OBIsPYafVqdORe | ||
17 | y54pEXbXiAfSVUWgI4a9CsiWwcDX8vlaX9ZLLr+L2VmOfr6Yc5214yxzausZVvnUFjy6LUXotuEX | ||
18 | tSar4EW7XI9DjaZc1l985naMsTx9JUa5GyQ9J6PGqhosAKpKMGgKkFAHaOwE1/IwgAYJKoZIhvcN | ||
19 | AQcBMBQGCCqGSIb3DQMHBAieDfmz3WGbN6CABHgEpsLrNn0PAZTDUfNomDypvSCl5bQH+9cKm80m | ||
20 | upMV2r8RBiXS7OaP4SpCxq18afDTTPatvboHIoEX92taTbq8soiAgEs6raSGtEYZNvFL0IYqm7MA | ||
21 | o5HCOmjiEcInyPf14lL3HnPk10FaP3hh58qTHUh4LPYtL7UECOZELYnUfUVhAAAAAAAAAAAAAA== | ||
22 | |||
diff --git a/framework/domain/mimetreeparser/tests/interfacetest.cpp b/framework/domain/mimetreeparser/tests/interfacetest.cpp index fd828960..88691539 100644 --- a/framework/domain/mimetreeparser/tests/interfacetest.cpp +++ b/framework/domain/mimetreeparser/tests/interfacetest.cpp | |||
@@ -18,6 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "interface.h" | 20 | #include "interface.h" |
21 | #include "interface_p.h" | ||
21 | 22 | ||
22 | #include <QTest> | 23 | #include <QTest> |
23 | 24 | ||
@@ -33,6 +34,15 @@ QByteArray readMailFromFile(const QString &mailFile) | |||
33 | class InterfaceTest : public QObject | 34 | class InterfaceTest : public QObject |
34 | { | 35 | { |
35 | Q_OBJECT | 36 | Q_OBJECT |
37 | private: | ||
38 | void printTree(const Part::Ptr &start, QString pre) | ||
39 | { | ||
40 | foreach (const auto &part, start->subParts()) { | ||
41 | qWarning() << QStringLiteral("%1* %2").arg(pre).arg(QString::fromLatin1(part->type())); | ||
42 | printTree(part,pre + QStringLiteral(" ")); | ||
43 | } | ||
44 | } | ||
45 | |||
36 | private slots: | 46 | private slots: |
37 | 47 | ||
38 | void testTextMail() | 48 | void testTextMail() |
@@ -43,10 +53,13 @@ private slots: | |||
43 | QCOMPARE(contentPart->availableContents(), ContentPart::PlainText); | 53 | QCOMPARE(contentPart->availableContents(), ContentPart::PlainText); |
44 | auto contentList = contentPart->content(ContentPart::PlainText); | 54 | auto contentList = contentPart->content(ContentPart::PlainText); |
45 | QCOMPARE(contentList.size(), 1); | 55 | QCOMPARE(contentList.size(), 1); |
46 | QCOMPARE(contentList[0]->content(), QStringLiteral("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/\n\n- GOG.com Team\n\n").toLocal8Bit()); | 56 | QCOMPARE(contentList[0]->content(), QStringLiteral("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/").toLocal8Bit()); |
47 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | 57 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); |
48 | QCOMPARE(contentList[0]->encryptions().size(), 0); | 58 | QCOMPARE(contentList[0]->encryptions().size(), 0); |
49 | QCOMPARE(contentList[0]->signatures().size(), 0); | 59 | QCOMPARE(contentList[0]->signatures().size(), 0); |
60 | |||
61 | contentList = contentPart->content(ContentPart::Html); | ||
62 | QCOMPARE(contentList.size(), 0); | ||
50 | } | 63 | } |
51 | 64 | ||
52 | void testTextAlternative() | 65 | void testTextAlternative() |
@@ -55,6 +68,19 @@ private slots: | |||
55 | auto contentPart = parser.collectContentPart(); | 68 | auto contentPart = parser.collectContentPart(); |
56 | QVERIFY((bool)contentPart); | 69 | QVERIFY((bool)contentPart); |
57 | QCOMPARE(contentPart->availableContents(), ContentPart::PlainText | ContentPart::Html); | 70 | QCOMPARE(contentPart->availableContents(), ContentPart::PlainText | ContentPart::Html); |
71 | auto contentList = contentPart->content(ContentPart::PlainText); | ||
72 | QCOMPARE(contentList.size(), 1); | ||
73 | QCOMPARE(contentList[0]->content(), QStringLiteral("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/\n").toLocal8Bit()); | ||
74 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | ||
75 | QCOMPARE(contentList[0]->encryptions().size(), 0); | ||
76 | QCOMPARE(contentList[0]->signatures().size(), 0); | ||
77 | |||
78 | contentList = contentPart->content(ContentPart::Html); | ||
79 | QCOMPARE(contentList.size(), 1); | ||
80 | QCOMPARE(contentList[0]->content(), QStringLiteral("<html><body><p><span>HTML</span> text</p></body></html>\n\n").toLocal8Bit()); | ||
81 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | ||
82 | QCOMPARE(contentList[0]->encryptions().size(), 0); | ||
83 | QCOMPARE(contentList[0]->signatures().size(), 0); | ||
58 | } | 84 | } |
59 | 85 | ||
60 | void testTextHtml() | 86 | void testTextHtml() |
@@ -63,6 +89,55 @@ private slots: | |||
63 | auto contentPart = parser.collectContentPart(); | 89 | auto contentPart = parser.collectContentPart(); |
64 | QVERIFY((bool)contentPart); | 90 | QVERIFY((bool)contentPart); |
65 | QCOMPARE(contentPart->availableContents(), ContentPart::Html); | 91 | QCOMPARE(contentPart->availableContents(), ContentPart::Html); |
92 | |||
93 | auto contentList = contentPart->content(ContentPart::PlainText); | ||
94 | QCOMPARE(contentList.size(), 0); | ||
95 | |||
96 | contentList = contentPart->content(ContentPart::Html); | ||
97 | QCOMPARE(contentList.size(), 1); | ||
98 | QCOMPARE(contentList[0]->content(), QStringLiteral("<html><body><p><span>HTML</span> text</p></body></html>").toLocal8Bit()); | ||
99 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | ||
100 | QCOMPARE(contentList[0]->encryptions().size(), 0); | ||
101 | QCOMPARE(contentList[0]->signatures().size(), 0); | ||
102 | } | ||
103 | |||
104 | void testSMimeEncrypted() | ||
105 | { | ||
106 | Parser parser(readMailFromFile("smime-encrypted.mbox")); | ||
107 | printTree(parser.d->mTree,QString()); | ||
108 | auto contentPart = parser.collectContentPart(); | ||
109 | QVERIFY((bool)contentPart); | ||
110 | QCOMPARE(contentPart->availableContents(), ContentPart::PlainText); | ||
111 | auto contentList = contentPart->content(ContentPart::PlainText); | ||
112 | QCOMPARE(contentList.size(), 1); | ||
113 | QCOMPARE(contentList[0]->content(), QStringLiteral("The quick brown fox jumped over the lazy dog.").toLocal8Bit()); | ||
114 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | ||
115 | } | ||
116 | |||
117 | void testOpenPGPEncryptedAttachment() | ||
118 | { | ||
119 | Parser parser(readMailFromFile("openpgp-encrypted-attachment-and-non-encrypted-attachment.mbox")); | ||
120 | printTree(parser.d->mTree,QString()); | ||
121 | auto contentPart = parser.collectContentPart(); | ||
122 | QVERIFY((bool)contentPart); | ||
123 | QCOMPARE(contentPart->availableContents(), ContentPart::PlainText); | ||
124 | auto contentList = contentPart->content(ContentPart::PlainText); | ||
125 | QCOMPARE(contentList.size(), 1); | ||
126 | QCOMPARE(contentList[0]->content(), QStringLiteral("test text").toLocal8Bit()); | ||
127 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | ||
128 | } | ||
129 | |||
130 | void testOpenPPGInline() | ||
131 | { | ||
132 | Parser parser(readMailFromFile("openpgp-inline-charset-encrypted.mbox")); | ||
133 | printTree(parser.d->mTree,QString()); | ||
134 | auto contentPart = parser.collectContentPart(); | ||
135 | QVERIFY((bool)contentPart); | ||
136 | QCOMPARE(contentPart->availableContents(), ContentPart::PlainText); | ||
137 | auto contentList = contentPart->content(ContentPart::PlainText); | ||
138 | QCOMPARE(contentList.size(), 1); | ||
139 | QCOMPARE(contentList[0]->content(), QStringLiteral("asdasd asd asd asdf sadf sdaf sadf äöü").toLocal8Bit()); | ||
140 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | ||
66 | } | 141 | } |
67 | }; | 142 | }; |
68 | 143 | ||