From 054d122ce2126beeeeb76a423ed84c1fac79306d Mon Sep 17 00:00:00 2001 From: Till Adam Date: Wed, 16 Mar 2005 20:21:14 +0000 Subject: [PATCH] Clear out all original headers apart from the content description ones when inline forwarding because otherwise they are falsely inherited by the fowarded mail. I've tried to thoroughly regression test it, and even inline forwarding opaque smime signed and encrypted mails with attachments still works. If you are using inline forwarding, please give it a try. If it works in all cases, we can backport it. svn path=/trunk/kdepim/; revision=398184 --- kmmessage.cpp | 60 +++++++++++++-------------------------------------- 1 file changed, 15 insertions(+), 45 deletions(-) diff --git a/kmmessage.cpp b/kmmessage.cpp index 6def79fad..a9fa0cb51 100644 --- a/kmmessage.cpp +++ b/kmmessage.cpp @@ -1157,11 +1157,25 @@ KMMessage* KMMessage::createForward() QString id; msg->fromDwString( this->asDwString() ); - msg->cleanupHeader(); // remember the type and subtype, initFromMessage sets the contents type to // text/plain, via initHeader, for unclear reasons const int type = msg->type(); const int subtype = msg->subtype(); + + // Strip out all headers apart from the content description ones, because we + // don't want to inherit them. + DwHeaders& header = msg->mMsg->Headers(); + DwField* field = header.FirstField(); + DwField* nextField; + while (field) + { + nextField = field->Next(); + if ( ! QString( field->FieldNameStr().c_str() ).contains( "ontent" ) ) + header.RemoveField(field); + field = nextField; + } + msg->mMsg->Assemble(); + msg->initFromMessage( this ); //restore type msg->setType( type ); @@ -1173,51 +1187,7 @@ KMMessage* KMMessage::createForward() msg->setCharset(encoding); msg->setSubject( forwardSubject() ); - msg->removePrivateHeaderFields(); - msg->removeHeaderField( "Sender" ); - -#ifdef BROKEN_FOR_OPAQUE_SIGNED_OR_ENCRYPTED_MAILS - QCString str = codecForName(encoding)->fromUnicode(st); - msg->setBody(str); - - if (numBodyParts() > 0) - { - msg->setType( DwMime::kTypeMultipart ); - msg->setSubtype( DwMime::kSubtypeMixed ); - msg->headers().ContentType().CreateBoundary( 0 ); - msg->headers().ContentType().Assemble(); - - msgPart.setTypeStr("text"); - msgPart.setSubtypeStr("plain"); - msgPart.setCharset(encoding); - msgPart.setBody(str); - msg->addBodyPart(&msgPart); - - bool outsideRfc822 = true; - for ( int i = 0; i < numBodyParts(); i++) - { - bodyPart(i, &msgPart); - QCString mimeType( msgPart.typeStr() + '/' + msgPart.subtypeStr() ); - if ( kasciistricmp( mimeType, "message/rfc822" ) != 0 ) // != message/rfc822 - outsideRfc822 = true; - // don't add the detached signature as attachment when forwarding a - // PGP/MIME signed message inline - if( outsideRfc822 && - kasciistricmp( mimeType, "application/pgp-signature" ) != 0 ) { // != application/pgp-signature - if (i > 0 || kasciistricmp(msgPart.typeStr(),"text") != 0) - msg->addBodyPart(&msgPart); - } - // avoid kind of recursive attaching of rfc822 parts - if ( kasciistricmp( mimeType, "message/rfc822" ) == 0 ) // == message/rfc822 - outsideRfc822 = false; - } - } -#endif // BROKEN_FOR_OPAQUE_SIGNED_OR_ENCRYPTED_MAILS - - - // setStatus(KMMsgStatusForwarded); msg->link(this, KMMsgStatusForwarded); - return msg; }