summaryrefslogtreecommitdiffstats
path: root/melib
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-10-08 16:42:34 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-10-11 16:53:04 +0300
commitafee1e2be5fe0232e8c3c66a3a03a21ccc7635d6 (patch)
tree639fd65ebc0f3862104e1e334a54d4d158776fc1 /melib
parent08df7f39b269def5d4abfb0e525f3e9f6f2addda (diff)
melib/compose: fix wrong Content-Type on PGP signatures and message/rfc822
Diffstat (limited to 'melib')
-rw-r--r--melib/src/email/compose.rs24
1 files 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<AttachmentB
ret.push_str("--");
ret.push_str(&boundary);
ret.push_str("\r\n");
- print_attachment(ret, &kind, sub);
+ print_attachment(ret, sub);
}
ret.push_str("--");
ret.push_str(&boundary);
ret.push_str("--\n");
}
-fn print_attachment(ret: &mut String, kind: &MultipartType, a: AttachmentBuilder) {
+fn print_attachment(ret: &mut String, a: AttachmentBuilder) {
use ContentType::*;
match a.content_type {
ContentType::Text {
@@ -339,13 +339,27 @@ fn print_attachment(ret: &mut String, kind: &MultipartType, a: AttachmentBuilder
);
ret.push_str("\r\n");
}
- MessageRfc822 | PGPSignature => {
- 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;