From kmail-devel Wed Feb 04 09:53:31 2004 From: Till Adam Date: Wed, 04 Feb 2004 09:53:31 +0000 To: kmail-devel Subject: [PATCH] prevent KMail from eating all mail in a folder when Message-Id: <200402041054.47678.adam () kde ! org> X-MARC-Message: https://marc.info/?l=kmail-devel&m=107588848411475 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============1872500362==" --===============1872500362== Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-03=_nFMIAJvYkS7lI1H"; charset="us-ascii" Content-Transfer-Encoding: 7bit --Boundary-03=_nFMIAJvYkS7lI1H Content-Type: multipart/mixed; boundary="Boundary-01=_cEMIASS+V5qnpnZ" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_cEMIASS+V5qnpnZ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hey folks, it has come to our attention that there is a grave bug in KMail triggered b= y=20 filtering mail in an imap folder through spamc. For some reason (which we a= re=20 still hunting down) the message loses its UID and consequently a delete job= =20 is sent to the kio_imap slave without a UID. The slave unfortunately=20 interprets that as "expunge folder". :( The attached patch against the branch prevents that faulty delete job witho= ut=20 a UID from being sent to the slave thereby preventing the mail loss.=20 There is still a bug lurking there, but the patch prevents the worst case o= f=20 people losing their complete Inboxes.=20 Kindly consider applying it and please CC kmail-devel on replies. Till --Boundary-01=_cEMIASS+V5qnpnZ Content-Type: text/x-diff; charset="us-ascii"; name="KMail-inboxEater-BRANCH.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="KMail-inboxEater-BRANCH.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(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(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); --Boundary-01=_cEMIASS+V5qnpnZ-- --Boundary-03=_nFMIAJvYkS7lI1H Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQBAIMFntrsWGirveVsRAqzfAJwM8mvgpNUZhRtlT3nQOynZ0KqeTgCg10TD Ny47XvEpxF4s+c6qBYWO1vI= =tHHk -----END PGP SIGNATURE----- --Boundary-03=_nFMIAJvYkS7lI1H-- --===============1872500362== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ KMail developers mailing list KMail-devel@kde.org https://mail.kde.org/mailman/listinfo/kmail-devel --===============1872500362==--