diff --git a/melib/src/email/attachments.rs b/melib/src/email/attachments.rs index ccffe7a02..655067372 100644 --- a/melib/src/email/attachments.rs +++ b/melib/src/email/attachments.rs @@ -763,15 +763,9 @@ pub fn interpret_format_flowed(_t: &str) -> String { unimplemented!() } -fn decode_rfc822(_raw: &[u8]) -> Attachment { - // FIXME - let builder = AttachmentBuilder::new(b"message/rfc822 cannot be displayed"); - builder.build() -} +type Filter<'a> = Box) -> () + 'a>; -type Filter<'a> = Box) -> () + 'a>; - -fn decode_rec_helper<'a>(a: &'a Attachment, filter: &mut Option>) -> Vec { +fn decode_rec_helper<'a, 'b>(a: &'a Attachment, filter: &mut Option>) -> Vec { match a.content_type { ContentType::Other { .. } => Vec::new(), ContentType::Text { .. } => decode_helper(a, filter), @@ -780,8 +774,13 @@ fn decode_rec_helper<'a>(a: &'a Attachment, filter: &mut Option>) -> } ContentType::PGPSignature => Vec::new(), ContentType::MessageRfc822 => { - let temp = decode_rfc822(a.body()); - decode_rec(&temp, None) + if a.content_disposition.kind.is_inline() { + let b = AttachmentBuilder::new(a.body()).build(); + let ret = decode_rec_helper(&b, filter); + ret + } else { + b"message/rfc822 attachment".to_vec() + } } ContentType::Multipart { ref kind, @@ -820,11 +819,11 @@ fn decode_rec_helper<'a>(a: &'a Attachment, filter: &mut Option>) -> } } -pub fn decode_rec<'a>(a: &'a Attachment, mut filter: Option>) -> Vec { +pub fn decode_rec<'a, 'b>(a: &'a Attachment, mut filter: Option>) -> Vec { decode_rec_helper(a, &mut filter) } -fn decode_helper<'a>(a: &'a Attachment, filter: &mut Option>) -> Vec { +fn decode_helper<'a, 'b>(a: &'a Attachment, filter: &mut Option>) -> Vec { let charset = match a.content_type { ContentType::Text { charset: c, .. } => c, _ => Default::default(), @@ -861,6 +860,6 @@ fn decode_helper<'a>(a: &'a Attachment, filter: &mut Option>) -> Vec< ret } -pub fn decode<'a>(a: &'a Attachment, mut filter: Option>) -> Vec { +pub fn decode<'a, 'b>(a: &'a Attachment, mut filter: Option>) -> Vec { decode_helper(a, &mut filter) } diff --git a/src/components/mail/view.rs b/src/components/mail/view.rs index b7e04d060..726cfef26 100644 --- a/src/components/mail/view.rs +++ b/src/components/mail/view.rs @@ -332,16 +332,12 @@ impl MailView { } /// Returns the string to be displayed in the Viewer - fn attachment_to_text<'closure, 's: 'closure, 'context: 's>( - &'s mut self, - body: &'context Attachment, - context: &'context mut Context, - ) -> String { + fn attachment_to_text(&mut self, body: &Attachment, context: &mut Context) -> String { let finder = LinkFinder::new(); let coordinates = self.coordinates; let body_text = String::from_utf8_lossy(&decode_rec( body, - Some(Box::new(move |a: &'closure Attachment, v: &mut Vec| { + Some(Box::new(move |a: &Attachment, v: &mut Vec| { if a.content_type().is_text_html() { /* FIXME: duplication with view/html.rs */ if let Some(filter_invocation) = diff --git a/src/components/mail/view/envelope.rs b/src/components/mail/view/envelope.rs index 5a18f3aff..19a45f551 100644 --- a/src/components/mail/view/envelope.rs +++ b/src/components/mail/view/envelope.rs @@ -84,11 +84,7 @@ impl EnvelopeView { } /// Returns the string to be displayed in the Viewer - fn attachment_to_text<'closure, 's: 'closure, 'context: 's>( - &'s self, - body: &'context Attachment, - context: &'context mut Context, - ) -> String { + fn attachment_to_text(&self, body: &Attachment, context: &mut Context) -> String { let finder = LinkFinder::new(); let body_text = String::from_utf8_lossy(&decode_rec( &body,