Home GnuPG
Diffusion GpgOL 10721b1dccf4

Fix message save before decrypt handling

Description

Fix message save before decrypt handling

* src/mail.cpp (Mail::decryptVerify_o): Only restore msgclass
for S/MIME mails. Only save PGP Mails before decrypt if they
are encrypted.
* src/mailitem-events.cpp (WriteCancelIgnored): Only
fall through to cancel if the write happens after decryption.

The intention of the original code to restore the message class
before decryption was that the S/MIME Message are still set
on the server even if we locally changed them to GpgOL message
classes in the BeforeRead event. Using this to also restore
PGP classes caused an issue where PGP MultipartSigned mails
were treated as S/MIME Mails. Esp. in combination with
disabled S/MIME support this triggered a revert at the end
of working with the mail, which then caused buggy behavior
like duplicated attachments.

Additionally we now check if the decryption has actually
happend before we fall through to close in the uncancellable
write event. Since we could now observe that this event happens
in combination with marking a mail as Read. Which was misunderstood
in 1f9c757872b033e1be8199c4d488ac84bf8f07bd and attributed
to the explicit saving. So the explicit call to
oom_message->SetReadFlag(0); is no longer necessary. Fixing
issues where the read flag is set by Outlook at different times
depending on the Options.

Closing the mail this early might also have contributed to
endless loops of read + close which appeared to occur
more regularly with third party addins due to us closing
the mail once we have seen event 0xFC99.