From dcd397f776d938a772b9c904d55b7808ec7a80f9 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Tue, 30 Aug 2022 19:25:31 -0500 Subject: pgp: enable quoted replies of encrypted messages When quoting an encrypted message for reply, the quoted text is shown as "Version: 1.0". This is due to this being the first non-multipart text portion of the message, which is what the quoted reply logic looks for. Properly quote replies to encrypted messages by decrypting the message, and quoting the content. The message must be open in a message view in order to quote it (it must be decrypted, which is handled by the message viewer). Suggested-by: Moritz Poldrack Signed-off-by: Tim Culverhouse Tested-by: Jens Grassel --- lib/crypto/crypto.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/crypto/crypto.go') diff --git a/lib/crypto/crypto.go b/lib/crypto/crypto.go index 8f895b42..b7afe638 100644 --- a/lib/crypto/crypto.go +++ b/lib/crypto/crypto.go @@ -31,3 +31,18 @@ func New(s string) Provider { return &pgp.Mail{} } } + +func IsEncrypted(bs *models.BodyStructure) bool { + if bs == nil { + return false + } + if bs.MIMEType == "application" && bs.MIMESubType == "pgp-encrypted" { + return true + } + for _, part := range bs.Parts { + if IsEncrypted(part) { + return true + } + } + return false +} -- cgit