[Bug 132487] Messed up text conaining german umlauts in html messages when they were saved in drafts folder and opened again from there

Allen Winter <[email protected]>
Newsgroups gmane.comp.kde.devel.kmail
Message-ID <[email protected]>
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=132487         
winter kde org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From winter kde org  2007-03-16 23:06 -------
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="
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.