Bug 126714 - Incorrect display of email source
Summary: Incorrect display of email source
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: messageviewer (show other bugs)
Version: 1.9.1
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2006-05-04 10:32 UTC by DragonK
Modified: 2008-11-07 15:43 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Message which is not displayed properly (918.18 KB, application/octet-stream)
2006-05-04 10:35 UTC, DragonK
Details
Difference between source display and real meesage (149.45 KB, image/png)
2006-05-08 10:09 UTC, DragonK
Details

Note You need to log in before you can comment on or make changes to this bug.
Description DragonK 2006-05-04 10:32:26 UTC
Version:           1.9.1 (using KDE KDE 3.5.2)
Installed from:    Gentoo Packages
Compiler:          gcc version 3.4.6 (Gentoo 3.4.6, ssp-3.4.5-1.0, pie-8.7.9) 
OS:                Linux

When pressing V on a message, the source code is incorrectly displayed; the lines after 

Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

are missing. I'll try to create an attachment with the message, i hope it's not too big, but it seems it has something to do with the size of the message.
Comment 1 DragonK 2006-05-04 10:35:38 UTC
Created attachment 15905 [details]
Message which is not displayed properly
Comment 2 Ismail Onur Filiz 2006-05-06 10:09:14 UTC
I cannot reproduce. With my KMail 1.9.1, everything works fine. Does this happen to you with other messages too?
Comment 3 DragonK 2006-05-07 12:16:31 UTC
I've noticed some inconsistencies in the displayed source of some emails before, but generally the messages are displayed ok. 
With this particular message (the one attached before), the display error occured with all attachments in the message. If i deleted some of them, the source was showing up properly.

I'll provide some screenshots on Monday, and more messages with problems if i stumble across some.
Comment 4 DragonK 2006-05-08 10:09:34 UTC
Created attachment 15977 [details]
Difference between source display and real meesage

Here is a screenshot with the problem. I tried to change the font of the
message source viewer to match the one in kate, but i couldn't (should i ask
for a feature? :P or am I blind and I didn't see where to change it).
Comment 5 DragonK 2006-05-08 10:17:26 UTC
I've checked with another machine running Gentoo, Kmail 1.9.1 and the same happens. Unfortunately, it's a machine on the same subnet, using the same mail server (therefore same configurations). If you need any more informations on packages installed, libs, feel free to ask.
Comment 6 Ismail Onur Filiz 2006-05-16 10:42:55 UTC
I'm sorry, you are right. I rechecked, and the part you indicated is not shown. 

The problem is with how QTextEdit handles text files. When the text format is set to Qt::LogText , it is not rendered as plain text, but rather as a limited html. Therefore, certain parts are not shown. A possible fix is:

Index: mailsourceviewer.cpp
===================================================================
--- mailsourceviewer.cpp        (revision 541373)
+++ mailsourceviewer.cpp        (working copy)
@@ -74,11 +74,15 @@ void MailSourceViewer::setText( const QS
   delete mSourceHighLighter; mSourceHighLighter = 0;
   if ( text.length() > 500000 ) {
     setTextFormat( Qt::LogText );
+    QString sanitized_text = text;
+    sanitized_text.replace('<',"&lt;");
+    sanitized_text.replace('>',"&gt;");
+    KTextBrowser::setText( sanitized_text );
   } else {
     setTextFormat( Qt::PlainText );
     mSourceHighLighter = new MailSourceHighlighter( this );
+    KTextBrowser::setText( text );
   }
-  KTextBrowser::setText( text );
 }

 }

But since by definition this requires a large QString to be deep copied, and since this bug is rather minor, I'm hesitant to commit.

I will fix it in trunk nevertheless, along with subclassing MailSourceViewer from a read-only KTextEdit instead of KTextBrowser, since a browser looks like overkill.
Comment 7 Ingo Klöcker 2006-05-16 22:41:06 UTC
Ismail: I have a very old patch here which subclasses MailSourceViewer from a read-only QTextEdit. I just never got around to committing the patch. But I guess it's not worth sending you the patch because apart from replacing KTextBrowser by QTextEdit it adds setReadOnly( true ); to the c'tor.

And deep copying the QString is really not a good idea. After all, we are using Qt::LogText instead of Qt::PlainText for large messages in order to keep the memory usage low. Maybe in Qt4 this is no longer necessary.
Comment 8 Rui G. 2008-09-17 12:53:07 UTC
I can't confirm the bug in kde 4.1.1 . The test-case is shown correctly from what I saw.
Comment 9 Michael Leupold 2008-11-07 15:43:45 UTC
I tried reproducing this by sending me the message the reporter attached. Works for me on 4.10.1.