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.
This commit is contained in:
Alan Morgan 2021-10-23 09:23:25 -06:00 committed by GitHub
parent eaa83b71ef
commit 09d3de5e6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
};