[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: [PATCH] prevent KMail from eating all mail in a folder when
From: Till Adam <adam () kde ! org>
Date: 2004-02-04 9:53:31
Message-ID: 200402041054.47678.adam () kde ! org
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Hey folks,
it has come to our attention that there is a grave bug in KMail triggered by
filtering mail in an imap folder through spamc. For some reason (which we are
still hunting down) the message loses its UID and consequently a delete job
is sent to the kio_imap slave without a UID. The slave unfortunately
interprets that as "expunge folder". :(
The attached patch against the branch prevents that faulty delete job without
a UID from being sent to the slave thereby preventing the mail loss.
There is still a bug lurking there, but the patch prevents the worst case of
people losing their complete Inboxes.
Kindly consider applying it and please CC kmail-devel on replies.
Till
["KMail-inboxEater-BRANCH.diff" (text/x-diff)]
Index: kmfolderimap.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/kmfolderimap.cpp,v
retrieving revision 1.163
diff -u -3 -p -r1.163 kmfolderimap.cpp
--- kmfolderimap.cpp 14 Jan 2004 23:05:04 -0000 1.163
+++ kmfolderimap.cpp 4 Feb 2004 08:53:56 -0000
@@ -1207,7 +1207,16 @@ void KMFolderImap::deleteMessage(KMMessa
{
KURL url = mAccount->getUrl();
KMFolderImap *msg_parent = static_cast<KMFolderImap*>(msg->parent());
- url.setPath(msg_parent->imapPath() + ";UID=" + msg->headerField("X-UID"));
+ QString uid = msg->headerField("X-UID");
+ /* If the uid is empty the delete job below will nuke all mail in the
+ folder, so we better safeguard against that. See ::expungeFolder, as
+ to why. :( */
+ if ( uid.isEmpty() ) {
+ kdDebug( 5006 ) << "KMFolderImap::deleteMessage: Attempt to delete "
+ "an empty UID. Aborting." << endl;
+ return;
+ }
+ url.setPath(msg_parent->imapPath() + ";UID=" + uid );
if ( mAccount->makeConnection() != ImapAccountBase::Connected )
return;
KIO::SimpleJob *job = KIO::file_delete(url, FALSE);
@@ -1228,7 +1237,11 @@ void KMFolderImap::deleteMessage(QPtrLis
KMFolderImap *msg_parent = static_cast<KMFolderImap*>(msgList.first()->parent());
for ( QStringList::Iterator it = sets.begin(); it != sets.end(); ++it )
{
- url.setPath(msg_parent->imapPath() + ";UID=" + *it);
+ QString uid = *it;
+ // Don't delete with no uid, that nukes the folder. Should not happen, but
+ // better safe than sorry.
+ if ( uid.isEmpty() ) continue;
+ url.setPath(msg_parent->imapPath() + ";UID=" + uid);
if ( mAccount->makeConnection() != ImapAccountBase::Connected )
return;
KIO::SimpleJob *job = KIO::file_delete(url, FALSE);
[Attachment #8 (application/pgp-signature)]
_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic