Bug 132487 - Messed up text conaining german umlauts in html messages when they were saved in drafts folder and opened again from there
Summary: Messed up text conaining german umlauts in html messages when they were saved...
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 111421 132681 135963 143021 143810 155655 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-08-16 11:08 UTC by Martin Runge
Modified: 2008-01-13 19:34 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch (1.51 KB, patch)
2006-12-15 21:56 UTC, Michal Bukovsky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Runge 2006-08-16 11:08:29 UTC
Version:            (using KDE KDE 3.5.4)
Installed from:    Ubuntu Packages
OS:                Linux

The error can easily reproduced:

1) Start a new mail
2) Edit Text containing german Umlauts (ä, ü, ö). More that one line to force a work wrap.
3) mark the text and change Font size to 20 to enforce a html-mail
4) save to drafts
5) open again from drafts you can see something like:

=C3=84 instead of Ä (A-Umlaut) 
=C3==9C instead of Ö (O-Umlaut)
=C3=96 instead of Ü (U-Umlaut)

and somtimes in the text ==2E or similar where linebreaks happened.

Sending the mail directly without storing it in as draft in between works well.
Comment 1 Martin Runge 2006-08-16 11:09:51 UTC
verified it with the OpenSuSE-10.1 KDE-3.5.4 vmware player image. Same problem.
Comment 2 Stefan Gehn 2006-08-16 11:41:47 UTC
Same here with KDE 3.5.4 on debian unstable. Previewing the draft looks ok, just the editor doesn't recognize it as html anymore.

Content-Transfer-Encoding switches from 7bit to quoted-printable if you add umlauts. The mail still contains text/ascii and text/html parts but kmail seems to pick up the ascii one when editing a quoted-printable encoded draft. Editing a mail without umlauts properly shows the text/html part.
Comment 3 Rudolf Kollien 2006-09-27 13:15:15 UTC
Can confirm this. 

KDE 3.5.4 "release 78.1" SuSE RPMs
KMail 1.9.4

In the sent mail folder the text appears corrupted too. When "prefer text view" is the favorit view option, than the mails are unreadable. The html part seems ok (including the umlauts).

Unfortunately sending such a mail resutlts in a corrupted text-only part on the receivers side too. To test this:

a) create a mail as specified above in steps 1) to 3)
b) address the mail to yourself.
c) ensure that "prefer html-view" is NOT active!
d) send and receive the mail
e) as the text view is prefered you see the text-only part in the preview window. And you will encounter the corrupted characters. The html part is ok.

BTW: My systems locale is UTF-8. But i think, that doesn't matter.

Comment 4 Bram Schoenmakers 2006-10-19 18:55:07 UTC
*** Bug 135963 has been marked as a duplicate of this bug. ***
Comment 5 Roland 2006-10-20 21:01:10 UTC
Bug confirmed with newer KMail release:

KDE 3.5.5 "release 19.1" SuSE 10.1
KMail 1.9.5
Comment 6 Michal Bukovsky 2006-12-15 21:56:28 UTC
Created attachment 18944 [details]
patch

The bug is caused inserting not transfer encoding decoded part into editor in
KMComposeWin::setMsg method. This patch add support for decoding transfer
encoding and respect charset html part.
Comment 7 Michal Bukovsky 2006-12-18 11:50:42 UTC
*** This bug has been confirmed by popular vote. ***
Comment 8 Bram Schoenmakers 2007-03-09 23:13:51 UTC
*** Bug 111421 has been marked as a duplicate of this bug. ***
Comment 9 Bram Schoenmakers 2007-03-09 23:16:04 UTC
*** Bug 132681 has been marked as a duplicate of this bug. ***
Comment 10 Ferdinand Gassauer 2007-03-10 07:11:31 UTC
I can confirm that saving HTML Umlaute to draft destroys the characters as described. 

Sending HTML works for me.
Comment 11 Ferdinand Gassauer 2007-03-10 07:23:17 UTC
Oh I forgot to mention that I am on KDE 3.5.6  / SVN 
Comment 12 Thomas McGuire 2007-03-16 13:30:17 UTC
*** Bug 143021 has been marked as a duplicate of this bug. ***
Comment 13 Thomas McGuire 2007-03-16 13:33:36 UTC
The KMail developers do not monitor the bug system very closely, so they probably did not see the patch yet.

Michal (or somebody else), please try to contact the #kontact IRC channel or the kdepim mailing list to get the patch reviewed & accepted.
Comment 14 Allen Winter 2007-03-16 23:06:19 UTC
SVN commit 643332 by winterz:

SVN commit 643330 by winterz:

Fix "Messed up text conaining german umlauts in html messages when they were
saved in drafts folder and opened again from there".

Patch from  Michal Bukovsky, thanks Michal!

BUGS: 132487


 M  +19 -9     kmcomposewin.cpp  


--- branches/KDE/3.5/kdepim/kmail/kmcomposewin.cpp #643331:643332
@@ -1844,20 +1844,32 @@
 
   mEditor->setText( otp.textualContent() );
   mCharset = otp.textualContentCharset();
-  if ( mCharset.isEmpty() )
-    mCharset = mMsg->charset();
-  if ( mCharset.isEmpty() )
-    mCharset = mDefCharset;
-  setCharset( mCharset );
-
   if ( partNode * n = root->findType( DwMime::kTypeText, DwMime::kSubtypeHtml ) )
     if ( partNode * p = n->parentNode() )
       if ( p->hasType( DwMime::kTypeMultipart ) &&
            p->hasSubType( DwMime::kSubtypeAlternative ) )
         if ( mMsg->headerField( "X-KMail-Markup" ) == "true" ) {
           toggleMarkup( true );
-          mEditor->setText(n->encodedBody() );
+
+          // get cte decoded body part
+          mCharset = n->msgPart().charset();
+          QCString bodyDecoded = n->msgPart().bodyDecoded();
+
+          // respect html part charset
+          const QTextCodec *codec = KMMsgBase::codecForName( mCharset );
+          if ( codec ) {
+            mEditor->setText( codec->toUnicode( bodyDecoded ) );
+          } else {
+            mEditor->setText( QString::fromLocal8Bit( bodyDecoded ) );
+          }
         }
+
+  if ( mCharset.isEmpty() )
+    mCharset = mMsg->charset();
+  if ( mCharset.isEmpty() )
+    mCharset = mDefCharset;
+  setCharset( mCharset );
+
   /* Handle the special case of non-mime mails */
   if ( mMsg->numBodyParts() == 0 && otp.textualContent().isEmpty() ) {
     mCharset=mMsg->charset();
@@ -1875,8 +1887,6 @@
     } else
       mEditor->setText(QString::fromLocal8Bit(bodyDecoded));
   }
-
-
 #ifdef BROKEN_FOR_OPAQUE_SIGNED_OR_ENCRYPTED_MAILS
   const int num = mMsg->numBodyParts();
   kdDebug(5006) << "KMComposeWin::setMsg() mMsg->numBodyParts="
Comment 15 Thomas McGuire 2007-04-03 23:33:14 UTC
*** Bug 143810 has been marked as a duplicate of this bug. ***
Comment 16 Ronny Standtke 2007-08-11 18:57:32 UTC
According to Comment#14 this bug is fixed. I just updated to KDE-3.5.7 and the bug is still present. How do I reopen this bug?
Comment 17 Bram Schoenmakers 2007-08-11 19:52:09 UTC
Reopening due to comment 16.
Comment 18 Ronny Standtke 2007-08-11 22:58:33 UTC
Ouch. If I will ever get asked "What is your most embarrassing KDE moment?" my answer will probably Bug#132487 Comment#16. I am running Debian testing and while KDE was updated to 3.5.7 I just noticed that kontact is still at version 3.5.5.dfsg.1-6.
I am very sorry for the confusion!
Comment 19 Thomas McGuire 2007-08-12 12:55:53 UTC
Closing due to comment #18.
Comment 20 Thomas McGuire 2008-01-13 19:34:55 UTC
*** Bug 155655 has been marked as a duplicate of this bug. ***