melib/src/email/address.rs: Fix invalid UTF8 panic

In StrBuilder::display there's an assumption that the string is valid utf-8 but if an email contains an invalid string inside the MIME encoded word part the conversion panics. Change it to a lossy UTF-8 conversion instead. Fixes #19

Reported-By: cycomanic
async
Manos Pitsidianakis 2020-04-02 08:19:54 +03:00
parent e034f4dd52
commit 6ccb9d3d75
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
1 changed files with 1 additions and 1 deletions

View File

@ -176,7 +176,7 @@ impl StrBuilder {
pub fn display<'a>(&self, s: &'a [u8]) -> String {
let offset = self.offset;
let length = self.length;
String::from_utf8(s[offset..offset + length].to_vec()).unwrap()
String::from_utf8_lossy(&s[offset..offset + length]).to_string()
}
pub fn display_bytes<'a>(&self, b: &'a [u8]) -> &'a [u8] {