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: cycomanicasync
parent
e034f4dd52
commit
6ccb9d3d75
|
@ -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] {
|
||||
|
|
Loading…
Reference in New Issue