Version: 2.1.1 (using KDE 4.6.5) OS: FreeBSD A mail claiming to have gb2312 encoding (but almost exclusively English text) crashes KMail2 upon viewing that mail. Reproducible: Always Steps to Reproduce: - Create new textfile - Name it crashtest.msg - Fill with the following: Return-path: <person@somechinesecompany.example.org> Envelope-to: me@mypersonaldomain.example.org Delivery-date: Wed, 10 Aug 2011 03:44:48 +0200 Received: from [621.397.520.573] (helo=somemx.somechinesecompany.example.org) From: <person@somechinesecompany.example.org> Reply-To: person@somechinesecompany.example.org To: me@mypersonaldomain.example.org Date: Wed,10 aug 2011 09:37:29 +0800 X-Mailer: SMail MIME-Version: 1.0 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable Message-ID: <123456789@person@somechinesecompany.example.org> Subject: Foo bar - Save textfile - Open with KMail2 ( or from context-menu in Dolphin) To fix the problem: - Open message with your favorite text-editor - change header like so: charset="UTF-8" Actual Results: Application: KMail (kmail), signal: Segmentation fault: 11 Expected Results: No crash The mail I received displayed this problem and the text I slammed together under 'steps to reproduce' also exhibits this problem
backtrace ?
I try your method but works fine here no crash.
I'm afraid the backtrace won't be of much help. I'll try to get kdepim to rebuild with debugging. This one is without: http://heesakkers.info/showandtell/kmail-20110817-235648.kcrash.txt
Thanks. Perhaps you can forward email in private if possible. Perhaps I will able to reproduce it.
The debugging rebuild was surprisingly simple: http://heesakkers.info/showandtell/kmail-20110818-003415.kcrash.txt
pasting inline: Thread 3 (Thread 80fc041c0 (LWP 100481/kmail)): [KCrash Handler] #7 0x0000000802ea9717 in KMime::Content::decodedText () from /usr/local/kde4/lib/libkmime.so.5 #8 0x0000000808d4bea9 in MessageViewer::ObjectTreeParser::processTextHtmlSubtype () from /usr/local/kde4/lib/libmessageviewer.so.5 #9 0x0000000808cfde22 in (anonymous namespace)::TextHtmlBodyPartFormatter::process () from /usr/local/kde4/lib/libmessageviewer.so.5 #10 0x0000000808d5c648 in MessageViewer::ObjectTreeParser::parseObjectTreeInternal () from /usr/local/kde4/lib/libmessageviewer.so.5 #11 0x0000000808d8cb2e in MessageViewer::ViewerPrivate::parseContent () from /usr/local/kde4/lib/libmessageviewer.so.5 #12 0x0000000808d8e12b in MessageViewer::ViewerPrivate::displayMessage () from /usr/local/kde4/lib/libmessageviewer.so.5 #13 0x0000000808d90196 in MessageViewer::ViewerPrivate::updateReaderWin () from /usr/local/kde4/lib/libmessageviewer.so.5 #14 0x0000000808da1e3d in MessageViewer::ViewerPrivate::qt_metacall () from /usr/local/kde4/lib/libmessageviewer.so.5 #15 0x00000008049f877a in QMetaObject::activate () from /usr/local/lib/qt4/libQtCore.so.4
Christophe do you success to reproduce it ?
no, maybe a real message using chinese symbols would help.
I tested this with kdepim-4.7.1 and kdepimlibs-4.7.1 so YMMV The problem is a NULL pointer reference in Content::decodedText() , kmime/kmime_content.cpp This patch fixes it. The code is borrowed from Content::fromUnicodeString(). --- kmime/kmime_content.cpp.orig 2011-09-26 13:33:53.000000000 -0500 +++ kmime/kmime_content.cpp 2011-09-26 14:35:15.000000000 -0500 @@ -408,6 +408,12 @@ QTextCodec *codec = KGlobal::charsets()->codecForName( QLatin1String( contentType()->charset() ), ok ); + if ( !ok || codec == NULL ) { // no suitable codec found => try local settings and hope the best ;-) + codec = KGlobal::locale()->codecForEncoding(); + QByteArray chset = KGlobal::locale()->encoding(); + contentType()->setCharset( chset ); + } + QString s = codec->toUnicode( d_ptr->body.data(), d_ptr->body.length() ); if ( trimText || removeTrailingNewlines ) {
Yes, patching kdepimlibs4 with this patch fixes the problem for me. Great work, thanks!
Git commit 8fc508c5f90149f8b97e0f3560f81f92b2bea7ac by Montel Laurent. Committed on 27/09/2011 at 09:08. Pushed by mlaurent into branch 'master'. Fix Bug 279809 - KMail2 crash on viewing mail in gb2312 encoding, edit to UTF-8 fixes it Patch from Axel Gonzalez tested by Oliver The code is borrowed from Content::fromUnicodeString(). FIXED-IN:4.7.2 BUG: 279809 M +6 -1 kmime/kmime_content.cpp http://commits.kde.org/kdepimlibs/8fc508c5f90149f8b97e0f3560f81f92b2bea7ac
Git commit 027da4d98f9b9099a51db4e8091de425acbea0f9 by Montel Laurent. Committed on 27/09/2011 at 09:08. Pushed by mlaurent into branch 'KDE/4.7'. Fix Bug 279809 - KMail2 crash on viewing mail in gb2312 encoding, edit to UTF-8 fixes it Patch from Axel Gonzalez tested by Oliver The code is borrowed from Content::fromUnicodeString(). FIXED-IN:4.7.2 BUG: 279809 (cherry picked from commit 8fc508c5f90149f8b97e0f3560f81f92b2bea7ac) M +6 -1 kmime/kmime_content.cpp http://commits.kde.org/kdepimlibs/027da4d98f9b9099a51db4e8091de425acbea0f9
Ok thanks for this patch. I applied to 4.7.2/master. Regards