From afee1e2be5fe0232e8c3c66a3a03a21ccc7635d6 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Thu, 8 Oct 2020 16:42:34 +0300 Subject: [PATCH] melib/compose: fix wrong Content-Type on PGP signatures and message/rfc822 --- melib/src/email/compose.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/melib/src/email/compose.rs b/melib/src/email/compose.rs index 1a7ad905..a4d85418 100644 --- a/melib/src/email/compose.rs +++ b/melib/src/email/compose.rs @@ -268,7 +268,7 @@ impl Draft { ret.push_str(&self.body); } else if self.body.is_empty() && self.attachments.len() == 1 { let attachment = std::mem::replace(&mut self.attachments, Vec::new()).remove(0); - print_attachment(&mut ret, &Default::default(), attachment); + print_attachment(&mut ret, attachment); } else { let mut parts = Vec::with_capacity(self.attachments.len() + 1); let attachments = std::mem::replace(&mut self.attachments, Vec::new()); @@ -301,14 +301,14 @@ fn build_multipart(ret: &mut String, kind: MultipartType, parts: Vec { - ret.push_str(&format!("Content-Type: {}; charset=\"utf-8\"\r\n", kind)); + MessageRfc822 => { + ret.push_str(&format!( + "Content-Type: {}; charset=\"utf-8\"\r\n", + a.content_type + )); ret.push_str("Content-Disposition: attachment\r\n"); ret.push_str("\r\n"); ret.push_str(&String::from_utf8_lossy(a.raw())); ret.push_str("\r\n"); } + PGPSignature => { + ret.push_str(&format!( + "Content-Type: {}; charset=\"utf-8\"; name=\"signature.asc\"\r\n", + a.content_type + )); + ret.push_str("Content-Description: Digital signature\r\n"); + ret.push_str("Content-Disposition: inline\r\n"); + ret.push_str("\r\n"); + ret.push_str(&String::from_utf8_lossy(a.raw())); + ret.push_str("\r\n"); + } _ => { let content_transfer_encoding: ContentTransferEncoding = ContentTransferEncoding::Base64;