From 4795cb5ce35fa74d00976b972edcc4b84d296a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Wed, 9 Nov 2016 11:18:54 +0100 Subject: Generate correct contents for AttachmentsParts --- framework/domain/mimetreeparser/interface.cpp | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'framework') diff --git a/framework/domain/mimetreeparser/interface.cpp b/framework/domain/mimetreeparser/interface.cpp index 181aa0a9..283ced9b 100644 --- a/framework/domain/mimetreeparser/interface.cpp +++ b/framework/domain/mimetreeparser/interface.cpp @@ -805,10 +805,19 @@ void SinglePartPrivate::fillFrom(MimeTreeParser::HtmlMessagePart::Ptr part) void SinglePartPrivate::fillFrom(MimeTreeParser::AttachmentMessagePart::Ptr part) { - q->reachParentD()->createMailMime(part.staticCast()); - mType = q->mailMime()->mimetype().name().toUtf8(); - mContent.clear(); - mContent.append(std::make_shared(q->mailMime()->decodedContent(), q)); + QMimeDatabase mimeDb; + q->reachParentD()->createMailMime(part.staticCast()); + const auto mimetype = q->mailMime()->mimetype(); + const auto content = q->mailMime()->decodedContent(); + mType = mimetype.name().toUtf8(); + mContent.clear(); + if (mimetype == mimeDb.mimeTypeForName("text/plain")) { + mContent.append(std::make_shared(content, q)); + } else if (mimetype == mimeDb.mimeTypeForName("text/html")) { + mContent.append(std::make_shared(content, q)); + } else { + mContent.append(std::make_shared(content, q)); + } } SinglePart::SinglePart() @@ -978,16 +987,13 @@ QVector Parser::collectContentParts() const } const auto ctname = mime->mimetype().name().trimmed().toLower(); - bool mightContent = false; - - if (ctname.startsWith("text/") || ctname.startsWith("image/") || ctname.isEmpty()) { - mightContent = true; - } + bool mightContent = (content->type() != "Content"); //Content we understand const auto cd = mime->disposition(); if (cd && cd == MailMime::Inline) { return mightContent; } + if (cd && cd == MailMime::Attachment) { return false; } @@ -1039,11 +1045,7 @@ QVector Parser::collectAttachmentParts() const } const auto ctname = mime->mimetype().name().trimmed().toLower(); - bool mightContent = false; - - if (ctname.startsWith("text/") || ctname.startsWith("image/") || ctname.isEmpty()) { - mightContent = true; - } + bool mightContent = (content->type() != "Content"); //Content we understand const auto cd = mime->disposition(); if (cd && cd == MailMime::Inline) { -- cgit v1.2.3