From e8fb7de6fc6a9c5e56fd827e65745a0781761b3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Tue, 8 Nov 2016 16:23:19 +0100 Subject: better desciion between attachment/content --- framework/domain/mimetreeparser/interface.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'framework') diff --git a/framework/domain/mimetreeparser/interface.cpp b/framework/domain/mimetreeparser/interface.cpp index 7e9497c0..181aa0a9 100644 --- a/framework/domain/mimetreeparser/interface.cpp +++ b/framework/domain/mimetreeparser/interface.cpp @@ -976,18 +976,23 @@ 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; + } + const auto cd = mime->disposition(); if (cd && cd == MailMime::Inline) { - // explict "inline" disposition: - return true; + return mightContent; } if (cd && cd == MailMime::Attachment) { - // explicit "attachment" disposition: return false; } - const auto ct = mime->mimetype(); - if (ct.name().trimmed().toLower() == "text" && ct.name().trimmed().isEmpty() && + if ((ctname.startsWith("text/") || ctname.isEmpty()) && (!mime || mime->filename().trimmed().isEmpty())) { // text/* w/o filename parameter: return true; @@ -1032,10 +1037,18 @@ 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; + } + const auto cd = mime->disposition(); if (cd && cd == MailMime::Inline) { // explict "inline" disposition: - return false; + return !mightContent; } if (cd && cd == MailMime::Attachment) { // explicit "attachment" disposition: @@ -1043,7 +1056,7 @@ QVector Parser::collectAttachmentParts() const } const auto ct = mime->mimetype(); - if (ct.name().trimmed().toLower() == "text" && ct.name().trimmed().isEmpty() && + if ((ctname.startsWith("text/") || ctname.isEmpty()) && (!mime || mime->filename().trimmed().isEmpty())) { // text/* w/o filename parameter: return false; -- cgit v1.2.3