From a6d557d694c39bcf8f180f561ecfbe369a266785 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sat, 25 Aug 2018 12:05:24 +0300 Subject: [PATCH] Don't insert newlines between multipart attachments Closes #34 --- melib/src/mailbox/email/attachments.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/melib/src/mailbox/email/attachments.rs b/melib/src/mailbox/email/attachments.rs index 6ce3d13b3..9fa39feec 100644 --- a/melib/src/mailbox/email/attachments.rs +++ b/melib/src/mailbox/email/attachments.rs @@ -211,6 +211,7 @@ impl AttachmentBuilder { continue; } }; + let body_slice = { let offset = (body.as_ptr() as usize).wrapping_sub(a.as_ptr() as usize); SliceBuild::new(offset, body.len()) @@ -298,7 +299,6 @@ impl Attachment { MultipartType::Mixed | MultipartType::Digest => { for a in sub_att_vec { a.get_text_recursive(text); - text.extend_from_slice(b"\n\n"); } } }, @@ -325,7 +325,7 @@ impl Attachment { .. } => { ret.push(att.clone()); - // TODO: Fix this, wrong count + // FIXME: Wrong count for a in sub_att_vec { count_recursive(a, ret); } @@ -356,11 +356,13 @@ impl Attachment { } } + pub fn interpret_format_flowed(_t: &str) -> String { //let mut n = String::with_capacity(t.len()); unimplemented!() } + fn decode_rfc822(_raw: &[u8]) -> Attachment { let builder = AttachmentBuilder::new(b""); builder.build() @@ -382,6 +384,7 @@ fn decode_rfc822(_raw: &[u8]) -> Attachment { type Filter = Box) -> ()>; + fn decode_rec_helper(a: &Attachment, filter: &Option) -> Vec { let mut ret = match a.content_type { ContentType::Unsupported { .. } => Vec::new(), @@ -405,7 +408,6 @@ fn decode_rec_helper(a: &Attachment, filter: &Option) -> Vec { let mut vec = Vec::new(); for a in sub_att_vec { vec.extend(decode_rec_helper(a, filter)); - vec.extend_from_slice(b"\n\n"); } vec }, @@ -415,9 +417,13 @@ fn decode_rec_helper(a: &Attachment, filter: &Option) -> Vec { } ret } + + pub fn decode_rec(a: &Attachment, filter: Option) -> Vec { decode_rec_helper(a, &filter) } + + fn decode_helper(a: &Attachment, filter: &Option) -> Vec { let charset = match a.content_type { ContentType::Text { charset: c, .. } => c, @@ -452,6 +458,8 @@ fn decode_helper(a: &Attachment, filter: &Option) -> Vec { ret } + + pub fn decode(a: &Attachment, filter: Option) -> Vec { decode_helper(a, &filter) }