Closed Bug 2098274 Opened 4 days ago Closed 18 hours ago

Saving or discarding a draft can delete an unrelated message in the folder it was saved to

Categories

(MailNews Core :: Composition, defect)

Thunderbird 81
defect

Tracking

(Not tracked)

RESOLVED FIXED
163 Branch

People

(Reporter: welpy-cw, Assigned: welpy-cw)

References

(Blocks 1 open bug)

Details

Attachments

(2 external files)

When an edited draft or template is saved, or an autosaved draft is discarded, the previous version is removed. Two code paths do this by taking the message key from the previous version's URI and deleting the message with that key in the folder the new version was saved to:

  • the IMAP fallback in nsMsgComposeSendListener::RemoveDraftOrTemplate(), used when the previous version's header isn't in the local database
  • RemoveDraft() in MsgComposeCommands.js

If the previous version was in a different folder (for example a draft opened from a subfolder of Drafts, or a template being edited while the autosave goes to Drafts), the same key can belong to an unrelated message in the target folder, and that message gets deleted.

Fix: only delete when the previous version's URI is the target folder's URI for that key.

RemoveDraft() also has an IMAP fallback that passes the non-existent nsMsgFolderFlags.Expunged as IMAP flags, so it has stored no flags since bug 453908. It can be removed.

Both RemoveDraftOrTemplate()'s IMAP fallback and RemoveDraft() took the
message key from the previous version's URI, but deleted the message with
that key in the folder the new version was saved to. If the previous version
was in another folder, the same key could belong to an unrelated message.
Only delete when the previous version's URI is that folder's URI for the key.

Also remove RemoveDraft()'s IMAP fallback. It passed the non-existent
nsMsgFolderFlags.Expunged as IMAP flags, so it has stored no flags since
bug 453908.

RFC 3501 requires the UID in any FETCH response caused by a UID command, but
the fake server's STORE handler left it out. Without the UID, the protocol
didn't record the flags of a message it hadn't fetched yet, so marking such a
message deleted triggered the "deleted msg not found in flagState" assertion
on Debug builds.

Target Milestone: --- → 163 Branch

Pushed by toby@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/d58980e4eee6
Include the UID in the fake IMAP server's responses to UID STORE. r=BenC
https://hg.mozilla.org/comm-central/rev/db3d896f33ae
Don't delete an unrelated message using a draft's key from another folder. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 18 hours ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: