diff options
-rw-r--r-- | framework/domain/mimetreeparser/interface.cpp | 13 | ||||
-rw-r--r-- | framework/domain/mimetreeparser/tests/interfacetest.cpp | 12 |
2 files changed, 18 insertions, 7 deletions
diff --git a/framework/domain/mimetreeparser/interface.cpp b/framework/domain/mimetreeparser/interface.cpp index b5e29e6b..ceb8caf3 100644 --- a/framework/domain/mimetreeparser/interface.cpp +++ b/framework/domain/mimetreeparser/interface.cpp | |||
@@ -64,6 +64,17 @@ QByteArray MailMime::cid() const | |||
64 | return d->mNode->contentID()->identifier(); | 64 | return d->mNode->contentID()->identifier(); |
65 | } | 65 | } |
66 | 66 | ||
67 | QByteArray MailMime::charset() const | ||
68 | { | ||
69 | if(!d->mNode || !d->mNode->contentType(false)) { | ||
70 | return QByteArray(); | ||
71 | } | ||
72 | if (d->mNode->contentType(false)) { | ||
73 | return d->mNode->contentType(false)->charset(); | ||
74 | } | ||
75 | return d->mNode->defaultCharset(); | ||
76 | } | ||
77 | |||
67 | bool MailMime::isFirstTextPart() const | 78 | bool MailMime::isFirstTextPart() const |
68 | { | 79 | { |
69 | if (!d->mNode || !d->mNode->topLevel()) { | 80 | if (!d->mNode || !d->mNode->topLevel()) { |
@@ -559,7 +570,6 @@ void SinglePartPrivate::fillFrom(MimeTreeParser::TextMessagePart::Ptr part) | |||
559 | auto d_ptr = new ContentPrivate; | 570 | auto d_ptr = new ContentPrivate; |
560 | d_ptr->mContent = mp->text().toLocal8Bit(); | 571 | d_ptr->mContent = mp->text().toLocal8Bit(); |
561 | d_ptr->mParent = q; | 572 | d_ptr->mParent = q; |
562 | d_ptr->mCodec = "utf-8"; | ||
563 | const auto enc = mp.dynamicCast<MimeTreeParser::EncryptedMessagePart>(); | 573 | const auto enc = mp.dynamicCast<MimeTreeParser::EncryptedMessagePart>(); |
564 | auto sig = mp.dynamicCast<MimeTreeParser::SignedMessagePart>(); | 574 | auto sig = mp.dynamicCast<MimeTreeParser::SignedMessagePart>(); |
565 | if (enc) { | 575 | if (enc) { |
@@ -574,6 +584,7 @@ void SinglePartPrivate::fillFrom(MimeTreeParser::TextMessagePart::Ptr part) | |||
574 | } | 584 | } |
575 | mContent.append(std::make_shared<PlainTextContent>(d_ptr)); | 585 | mContent.append(std::make_shared<PlainTextContent>(d_ptr)); |
576 | q->reachParentD()->createMailMime(part); | 586 | q->reachParentD()->createMailMime(part); |
587 | d_ptr->mCodec = q->mailMime()->charset(); | ||
577 | } | 588 | } |
578 | } | 589 | } |
579 | 590 | ||
diff --git a/framework/domain/mimetreeparser/tests/interfacetest.cpp b/framework/domain/mimetreeparser/tests/interfacetest.cpp index d52606c2..0259471e 100644 --- a/framework/domain/mimetreeparser/tests/interfacetest.cpp +++ b/framework/domain/mimetreeparser/tests/interfacetest.cpp | |||
@@ -144,7 +144,7 @@ private slots: | |||
144 | auto contentList = contentPart->content("plaintext"); | 144 | auto contentList = contentPart->content("plaintext"); |
145 | QCOMPARE(contentList.size(), 1); | 145 | QCOMPARE(contentList.size(), 1); |
146 | QCOMPARE(contentList[0]->content(), QStringLiteral("The quick brown fox jumped over the lazy dog.").toLocal8Bit()); | 146 | QCOMPARE(contentList[0]->content(), QStringLiteral("The quick brown fox jumped over the lazy dog.").toLocal8Bit()); |
147 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | 147 | QCOMPARE(contentList[0]->charset(), QStringLiteral("us-ascii").toLocal8Bit()); |
148 | QCOMPARE(contentList[0]->encryptions().size(), 1); | 148 | QCOMPARE(contentList[0]->encryptions().size(), 1); |
149 | QCOMPARE(contentList[0]->signatures().size(), 0); | 149 | QCOMPARE(contentList[0]->signatures().size(), 0); |
150 | auto contentAttachmentList = parser.collectAttachmentParts(); | 150 | auto contentAttachmentList = parser.collectAttachmentParts(); |
@@ -163,7 +163,7 @@ private slots: | |||
163 | auto contentList = contentPart->content("plaintext"); | 163 | auto contentList = contentPart->content("plaintext"); |
164 | QCOMPARE(contentList.size(), 1); | 164 | QCOMPARE(contentList.size(), 1); |
165 | QCOMPARE(contentList[0]->content(), QStringLiteral("test text").toLocal8Bit()); | 165 | QCOMPARE(contentList[0]->content(), QStringLiteral("test text").toLocal8Bit()); |
166 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | 166 | QCOMPARE(contentList[0]->charset(), QStringLiteral("us-ascii").toLocal8Bit()); |
167 | QCOMPARE(contentList[0]->encryptions().size(), 1); | 167 | QCOMPARE(contentList[0]->encryptions().size(), 1); |
168 | QCOMPARE(contentList[0]->signatures().size(), 1); | 168 | QCOMPARE(contentList[0]->signatures().size(), 1); |
169 | auto contentAttachmentList = parser.collectAttachmentParts(); | 169 | auto contentAttachmentList = parser.collectAttachmentParts(); |
@@ -178,7 +178,7 @@ private slots: | |||
178 | QCOMPARE(contentAttachmentList[1]->signatures().size(), 0); | 178 | QCOMPARE(contentAttachmentList[1]->signatures().size(), 0); |
179 | } | 179 | } |
180 | 180 | ||
181 | void testOpenPPGInline() | 181 | void testOpenPGPInline() |
182 | { | 182 | { |
183 | Parser parser(readMailFromFile("openpgp-inline-charset-encrypted.mbox")); | 183 | Parser parser(readMailFromFile("openpgp-inline-charset-encrypted.mbox")); |
184 | printTree(parser.d->mTree,QString()); | 184 | printTree(parser.d->mTree,QString()); |
@@ -192,7 +192,7 @@ private slots: | |||
192 | auto contentList = contentPart->content("plaintext"); | 192 | auto contentList = contentPart->content("plaintext"); |
193 | QCOMPARE(contentList.size(), 1); | 193 | QCOMPARE(contentList.size(), 1); |
194 | QCOMPARE(contentList[0]->content(), QStringLiteral("asdasd asd asd asdf sadf sdaf sadf äöü").toLocal8Bit()); | 194 | QCOMPARE(contentList[0]->content(), QStringLiteral("asdasd asd asd asdf sadf sdaf sadf äöü").toLocal8Bit()); |
195 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | 195 | QCOMPARE(contentList[0]->charset(), QStringLiteral("ISO-8859-15").toLocal8Bit()); |
196 | QCOMPARE(contentList[0]->encryptions().size(), 1); | 196 | QCOMPARE(contentList[0]->encryptions().size(), 1); |
197 | QCOMPARE(contentList[0]->signatures().size(), 1); | 197 | QCOMPARE(contentList[0]->signatures().size(), 1); |
198 | auto contentAttachmentList = parser.collectAttachmentParts(); | 198 | auto contentAttachmentList = parser.collectAttachmentParts(); |
@@ -213,11 +213,11 @@ private slots: | |||
213 | auto contentList = contentPart->content("plaintext"); | 213 | auto contentList = contentPart->content("plaintext"); |
214 | QCOMPARE(contentList.size(), 2); | 214 | QCOMPARE(contentList.size(), 2); |
215 | QCOMPARE(contentList[0]->content(), QStringLiteral("Not encrypted not signed :(\n\n").toLocal8Bit()); | 215 | QCOMPARE(contentList[0]->content(), QStringLiteral("Not encrypted not signed :(\n\n").toLocal8Bit()); |
216 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | 216 | QCOMPARE(contentList[0]->charset(), QStringLiteral("us-ascii").toLocal8Bit()); |
217 | QCOMPARE(contentList[0]->encryptions().size(), 0); | 217 | QCOMPARE(contentList[0]->encryptions().size(), 0); |
218 | QCOMPARE(contentList[0]->signatures().size(), 0); | 218 | QCOMPARE(contentList[0]->signatures().size(), 0); |
219 | QCOMPARE(contentList[1]->content(), QStringLiteral("some random text").toLocal8Bit()); | 219 | QCOMPARE(contentList[1]->content(), QStringLiteral("some random text").toLocal8Bit()); |
220 | QCOMPARE(contentList[1]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | 220 | QCOMPARE(contentList[1]->charset(), QStringLiteral("us-ascii").toLocal8Bit()); |
221 | QCOMPARE(contentList[1]->encryptions().size(), 1); | 221 | QCOMPARE(contentList[1]->encryptions().size(), 1); |
222 | QCOMPARE(contentList[1]->signatures().size(), 0); | 222 | QCOMPARE(contentList[1]->signatures().size(), 0); |
223 | auto contentAttachmentList = parser.collectAttachmentParts(); | 223 | auto contentAttachmentList = parser.collectAttachmentParts(); |