fix: do not run simplify() on dehtml() output

simplify() is written to process incoming plaintext messages
and extract footers and quotes from them.
Incoming messages contain various quote styles
and simplify() implements heuristics to detects them.

If dehtml() output is processed by simplify(),
simplify() heuristics may erroneously detect
footers and quotes in produced plaintext.

dehtml() should directly detect quotes
instead of converting them to plaintext quotes
for parsing with simplify().
This commit is contained in:
link2xt
2023-06-26 20:21:01 +00:00
parent 5fe94e8bce
commit 2d30afd212
5 changed files with 333 additions and 70 deletions

View File

@@ -1076,16 +1076,20 @@ impl MimeMessage {
Default::default()
} else {
let is_html = mime_type == mime::TEXT_HTML;
let out = if is_html {
if is_html {
self.is_mime_modified = true;
dehtml(&decoded_data).unwrap_or_else(|| {
if let Some(text) = dehtml(&decoded_data) {
text
} else {
dehtml_failed = true;
decoded_data.clone()
})
SimplifiedText {
text: decoded_data.clone(),
..Default::default()
}
}
} else {
decoded_data.clone()
};
simplify(out, self.has_chat_version())
simplify(decoded_data.clone(), self.has_chat_version())
}
};
self.is_mime_modified = self.is_mime_modified