[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    [Fwd: KMail bug (and half-patch)]
From:       Antonio Larrosa <antlarr () arrakis ! es>
Date:       2000-09-30 18:32:45
[Download RAW message or body]

Hi,

Some weeks ago, I sent this mail to Don Sanders, and told him that I'd continue
searching for the bug as soon as I had time. The problem is not only that I
didn't have time, but that I won't and Monday is the last day to commit the
bugfix.

I suppose Don is also busy and that's why it hasn't been fixed yet, so I
send the mail here in the hope that someone who has a bit of time (and is
somehow familiarized with kmail's code) can fix it.

Greetings,

-------- Original Message --------
From: Antonio Larrosa <antonio@larrosa.org>
Subject: KMail bug (and half-patch)
To: Don Sanders <sanders@kde.org>

Hi Don,

I've noticed KMail doesn't "code" the message body if it contains a
line starting by "From", as in:

>From here
to here

(note that I've not written any ">" characters,
but netscape did it :) )

To see the effects of not doing this, be sure that your outbox is
empty (unless you want to damage it :) ), then write a mail with
a line containing "From something", queue it, then quit KMail,
delete the .outbox.index file and try to open the output mbox
again, the mbox was corrupted so kmail thinks it contains
two messages !

I've attached my initial patch, but it doesn't work.
I've added a KMMessage::checkBodySyntax method that checks
for correct syntax (feel free to change the name if you want)
First, numBodyParts always returns 0 (I suppose it only
returns >0 when sending mime multiparts msgs). And then, body()
always returns an empty string (I've left the printf calls
so that you can see it).

Btw, I thought the correct way to fix it is by adding a blank
space before "From ", but netscape and plain mail convert
"From something.*" to ">From something.*"
"From " to ">From "
"From" to "From" (is not neccesary to change that)
so I decided to add a ">" instead of a " "

I hope this helps you a bit to fix that mbox corruption.

Greetings,

--
Antonio Larrosa Jimenez
KDE Core developer
antonio@larrosa.org        larrosa@kde.org
http://www.larrosa.org
KDE - The development framework of the future, today.
["kmail.diff" (text/plain)]

Index: kmcomposewin.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmcomposewin.cpp,v
retrieving revision 1.243
diff -u -r1.243 kmcomposewin.cpp
--- kmcomposewin.cpp	2000/09/03 18:08:22	1.243
+++ kmcomposewin.cpp	2000/09/04 16:49:09
@@ -1819,6 +1819,8 @@
       (mMsg->headerField("X-KMail-Transport") != kernel->msgSender()->transportString()))
     mMsg->setHeaderField("X-KMail-Transport", mTransport.currentText());
 
+  mMsg->checkBodySyntax();
+
   sentOk = (applyChanges() && kernel->msgSender()->send(mMsg, aSendNow));
   kernel->kbp()->idle();
 
Index: kmmessage.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmmessage.cpp,v
retrieving revision 1.126
diff -u -r1.126 kmmessage.cpp
--- kmmessage.cpp	2000/08/30 14:03:52	1.126
+++ kmmessage.cpp	2000/09/04 16:49:13
@@ -1988,3 +1988,37 @@
    mType.Assemble();
    printf("mType: %s\n",mType.AsString().c_str());
 }		
+
+//-----------------------------------------------------------------------------
+void KMMessage::checkBodySyntax()
+{
+   QRegExp from("\nFrom ");
+   KMMessagePart kmsgpart;
+   QString body;
+   printf("num body parts : %d\n",numBodyParts());
+
+   if (numBodyParts() == 0)
+   {
+     body=this->body();
+     printf("body length : %d\n",body.length());
+     if (body.find(from)){
+       body.replace(from,"\n>From ");
+       setBody(body);
+     }
+   } 
+   else 
+   {
+     for (int i=0; i < numBodyParts() ; i++){
+       bodyPart(i,&kmsgpart);
+       body=kmsgpart.body();
+       printf(body.latin1());
+       if (body.find(from)){
+         body.replace(from,"\n>From ");
+         kmsgpart.setBody(body);
+         setBodyPart(i,&kmsgpart);
+       }
+       
+     }
+   }
+  
+}
Index: kmmessage.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmmessage.h,v
retrieving revision 1.43
diff -u -r1.43 kmmessage.h
--- kmmessage.h	2000/08/30 14:03:52	1.43
+++ kmmessage.h	2000/09/04 16:49:14
@@ -289,8 +289,10 @@
   
   /** Set the message charset. */
   virtual void setCharset(const QString& aStr);
-
    				       
+  /** Set the message charset. */
+  virtual void checkBodySyntax();
+  
 #ifdef KRN
   /** Convert a normal References: header into a list of anchors
    to news URLs for the referred articles. Right now, only for KRN. */




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic