Bug 144779 - [PATCH] MultiPart message plain/text body encoding patch
Summary: [PATCH] MultiPart message plain/text body encoding patch
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: mime (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 97663 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-04-28 09:40 UTC by stanv
Modified: 2007-05-01 23:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description stanv 2007-04-28 09:40:09 UTC
Version:           3.5.6 (using KDE KDE 3.5.6)
Installed from:    Compiled From Sources
Compiler:          gcc version 4.1.1 
OS:                Linux

Hello.

Steps to reproduce bug:
1. Compose new email in some specific language (charset encoding == koi8r, utf8(with russian words), cp1251,...).
2. Use richedit icons (e.g. increase text size)
3. Send message.

kmail will send this message in two parts:
First part: message in HTML.
Second part: same message but in in plain text.

Second part will be broken. Kmail write second part with bad encoded body.

Here are patch, for correct this:
===========================================================
diff -ruN kdepim-3.5.6/kmail/messagecomposer.cpp kdepim-3.5.6-modified/kmail/messagecompos
er.cpp
--- kdepim-3.5.6/kmail/messagecomposer.cpp  2006-10-01 21:30:30 +0400
+++ kdepim-3.5.6-modified/kmail/messagecomposer.cpp 2007-04-27 15:18:35 +0400
@@ -2056,6 +2056,7 @@
     kdDebug(5006) << "Something is wrong and I can not get a codec." << endl;
     textbody = text.local8Bit();
   } else {
+    text=codec->toUnicode(text.latin1(), text.length());
     textbody = codec->fromUnicode( text );
   }
   if (textbody.isNull()) textbody = "";
===========================================================

This is because:
2049: QString text = hackConspiratorTextEdit->text();
return text already encoded as selected at MessageComposerWindow->Options->Set Encoding.

Example of bogus mail:
Erased head
From: xxxx <xxxxx>
To: xxxx@xxxx.xxx
Subject: HTML - koi8r
Date: Wed, 25 Apr 2007 11:50:04 +0400
User-Agent: KMail/1.9.6
MIME-Version: 1.0
Content-Type: multipart/alternative;
  boundary="Boundary-01=_sgwLGVR2Rq6T9jF"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Message-Id: <200704251150.04977.xxxx@xxxx.xx>

--Boundary-01=_sgwLGVR2Rq6T9jF
Content-Type: text/plain;
  charset="koi8-r"
Content-Transfer-Encoding: 7bit

????
--Boundary-01=_sgwLGVR2Rq6T9jF
Content-Type: text/html;
  charset="koi8-r"
Content-Transfer-Encoding: 8bit

<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans">
<p><span style="font-size:20pt;font-weight:600">ТЕСТ</span></p>
</body></html>
--Boundary-01=_sgwLGVR2Rq6T9jF--


Please notice 7bit and "????" (four question marks instead Russian "test" word).
Comment 1 Thomas McGuire 2007-04-29 19:13:48 UTC
Thanks for the patch.

The KMail developers are not monitoring the bug system very closely, so they will probably not see your patch here.
Please contact the KDE PIM team at the kde-pim mailinglist or the #kontact IRC channel to get your patch reviewed & commited.
Comment 2 Thomas McGuire 2007-04-29 19:16:51 UTC
*** Bug 97663 has been marked as a duplicate of this bug. ***
Comment 3 Allen Winter 2007-05-01 23:17:23 UTC
SVN commit 660183 by winterz:

fix for "MultiPart message plain/text body encoding" bug
Patch provided by stanv. Thanks!

BUGS: 144779


 M  +2 -1      messagecomposer.cpp  


--- branches/KDE/3.5/kdepim/kmail/messagecomposer.cpp #660182:660183
@@ -1593,7 +1593,7 @@
     mPerformingSignOperation = true;  // this lets the KMComposeWin know if it is safe to close the window.
     pgpSignedMsg( mEncodedBody, format );
     mPerformingSignOperation = false;
-    
+
     if ( mSignature.isEmpty() ) {
       kdDebug() << "signature was empty" << endl;
       mRc = false;
@@ -2049,6 +2049,7 @@
     kdDebug(5006) << "Something is wrong and I can not get a codec." << endl;
     textbody = text.local8Bit();
   } else {
+    text = codec->toUnicode( text.latin1(), text.length() );
     textbody = codec->fromUnicode( text );
   }
   if (textbody.isNull()) textbody = "";