From f9301c6c042546a86f28f2ddaccadca7bcf8b9a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Sun, 25 Mar 2018 20:20:07 +0200 Subject: [PATCH] kmail: Avoid setting charset on non-textual parts of emails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Slávek Banko (cherry picked from commit 3479159c7ff5c918af12e29a32367843f336b57f) --- kmail/kmcommands.cpp | 7 +++---- kmail/kmcomposewin.cpp | 1 - kmail/kmkernel.cpp | 3 ++- kmail/kmmessage.cpp | 7 +++++-- kmail/messagecomposer.cpp | 4 +++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/kmail/kmcommands.cpp b/kmail/kmcommands.cpp index 8b477924..a6185013 100644 --- a/kmail/kmcommands.cpp +++ b/kmail/kmcommands.cpp @@ -1350,13 +1350,10 @@ KMCommand::Result KMForwardAttachedCommand::execute() KMMessagePart *msgPart = new KMMessagePart; msgPart->setTypeStr("message"); msgPart->setSubtypeStr("rfc822"); - msgPart->setCharset(msg->charset()); msgPart->setName("forwarded message"); msgPart->setContentDescription(msg->from()+": "+msg->subject()); msgPart->setContentDisposition( "inline" ); - // THIS HAS TO BE AFTER setCte()!!!! msgPart->setMessageBody( KMail::Util::ByteArray( msg->asDwString() ) ); - msgPart->setCharset(""); fwdMsg->link(msg, KMMsgStatusForwarded); mWin->addAttach(msgPart); @@ -2893,7 +2890,9 @@ KMCommand::Result KMResendMessageCommand::execute() whiteList << "To" << "Cc" << "Bcc" << "Subject"; newMsg->sanitizeHeaders( whiteList ); - newMsg->setCharset(msg->codec()->mimeName()); + if( newMsg->type() == DwMime::kTypeText) { + newMsg->setCharset(msg->codec()->mimeName()); + } newMsg->setParent( 0 ); // make sure we have an identity set, default, if necessary diff --git a/kmail/kmcomposewin.cpp b/kmail/kmcomposewin.cpp index c0b66ab5..2add2b3a 100644 --- a/kmail/kmcomposewin.cpp +++ b/kmail/kmcomposewin.cpp @@ -3286,7 +3286,6 @@ void KMComposeWin::slotAttachProperties() } } } - if (msgPart->typeStr().lower() != "text") msgPart->setCharset(TQCString()); } //----------------------------------------------------------------------------- diff --git a/kmail/kmkernel.cpp b/kmail/kmkernel.cpp index fb22fca2..f998a74c 100644 --- a/kmail/kmkernel.cpp +++ b/kmail/kmkernel.cpp @@ -45,6 +45,7 @@ using TDERecentAddress::RecentAddresses; #include "kmsystemtray.h" #include "transportmanager.h" #include "importarchivedialog.h" +#include #include #include "kmailicalifaceimpl.h" @@ -574,7 +575,7 @@ int KMKernel::openComposer (const TQString &to, const TQString &cc, if( ! GlobalSettings::self()->exchangeCompatibleInvitations() ) { msgPart->setContentDisposition( attachContDisp ); } - if( !attachCharset.isEmpty() ) { + if( !attachCharset.isEmpty() && (msgPart->type() == DwMime::kTypeText) ) { // kdDebug(5006) << "KMKernel::openComposer set attachCharset to " // << attachCharset << endl; msgPart->setCharset( attachCharset ); diff --git a/kmail/kmmessage.cpp b/kmail/kmmessage.cpp index c33fdf6a..d9961478 100644 --- a/kmail/kmmessage.cpp +++ b/kmail/kmmessage.cpp @@ -3055,8 +3055,11 @@ void applyHeadersToMessagePart( DwHeaders& headers, KMMessagePart* aPart ) DwParameter *param = ct.FirstParameter(); while(param) { - if (!tqstricmp(param->Attribute().c_str(), "charset")) - aPart->setCharset(TQCString(param->Value().c_str()).lower()); + if (!tqstricmp(param->Attribute().c_str(), "charset")) { + if (aPart->type() == DwMime::kTypeText) { + aPart->setCharset(TQCString(param->Value().c_str()).lower()); + } + } else if (!tqstrnicmp(param->Attribute().c_str(), "name*", 5)) aPart->setName(KMMsgBase::decodeRFC2231String(KMMsgBase::extractRFC2231HeaderField( param->Value().c_str(), "name" ))); else { diff --git a/kmail/messagecomposer.cpp b/kmail/messagecomposer.cpp index 2a82da9e..9b5763dd 100644 --- a/kmail/messagecomposer.cpp +++ b/kmail/messagecomposer.cpp @@ -1251,7 +1251,9 @@ void MessageComposer::composeInlineOpenPGPMessage( KMMessage& theMessage, } mOldBodyPart.setContentDisposition( "inline" ); mOldBodyPart.setOriginalContentTypeStr( oldContentType.utf8() ); - mOldBodyPart.setCharset(mCharset); + if (mOldBodyPart.type() == DwMime::kTypeText) { + mOldBodyPart.setCharset(mCharset); + } addBodyAndAttachments( msg, splitInfo, false, false, mOldBodyPart, Kleo::InlineOpenPGPFormat ); mMessageList.push_back( msg ); if ( it == splitInfos.begin() ) {