From kde-core-devel Sat Sep 30 18:32:45 2000 From: Antonio Larrosa Date: Sat, 30 Sep 2000 18:32:45 +0000 To: kde-core-devel Subject: [Fwd: KMail bug (and half-patch)] X-MARC-Message: https://marc.info/?l=kde-core-devel&m=97034938331880 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------3CD489F355C0891C3D19BD43" This is a multi-part message in MIME format. --------------3CD489F355C0891C3D19BD43 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Subject: KMail bug (and half-patch) To: Don Sanders 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. --------------3CD489F355C0891C3D19BD43 Content-Type: text/plain; charset=us-ascii; name="kmail.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="kmail.diff" 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. */ --------------3CD489F355C0891C3D19BD43--