From 09d3de5e6fb680c9e763240c534fae3bd4624f93 Mon Sep 17 00:00:00 2001 From: Alan Morgan Date: Sat, 23 Oct 2021 09:23:25 -0600 Subject: [PATCH] parse raw message as ut8 lossy (#234) Reading a message raw uses uses utf_lossy to ensure the message can be read even if there is invalid utf8. --- src/domain/msg/msg_handler.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/domain/msg/msg_handler.rs b/src/domain/msg/msg_handler.rs index b444151..8195f5b 100644 --- a/src/domain/msg/msg_handler.rs +++ b/src/domain/msg/msg_handler.rs @@ -212,7 +212,8 @@ pub fn read<'a, OutputService: OutputServiceInterface, ImapService: ImapServiceI imap: &mut ImapService, ) -> Result<()> { let msg = if raw { - String::from_utf8(imap.find_raw_msg(&seq)?)? + // Emails don't always have valid utf8. Using "lossy" to display what we can. + String::from_utf8_lossy(&imap.find_raw_msg(&seq)?).into_owned() } else { imap.find_msg(&seq)?.fold_text_parts(text_mime) };