mirror of
https://github.com/chatmail/core.git
synced 2026-05-13 03:46:32 +03:00
let get_html() return first instead of last text
usually, there is at most one text/html and one text/plain part. multiple text/plain parts, are known only by mailinglist software that wants to add a footer but cannot alter the original content part - maybe because it is html and things are hard to stitch or maybe because the content part is cryptographically signed and cannot be altered therefore.
This commit is contained in:
13
src/html.rs
13
src/html.rs
@@ -108,9 +108,12 @@ impl HtmlMsgParser {
|
|||||||
|
|
||||||
/// Function iterates over all mime-parts
|
/// Function iterates over all mime-parts
|
||||||
/// and searches for text/plain and text/html parts and saves the
|
/// and searches for text/plain and text/html parts and saves the
|
||||||
/// last one found
|
/// first one found.
|
||||||
/// in the corresponding structure fields.
|
/// in the corresponding structure fields.
|
||||||
/// Usually, there is at most one plain-text and one HTML-text part.
|
///
|
||||||
|
/// Usually, there is at most one plain-text and one HTML-text part,
|
||||||
|
/// multiple plain-text parts might be used for mailinglist-footers,
|
||||||
|
/// therefore we use the first one.
|
||||||
fn collect_texts_recursive<'a>(
|
fn collect_texts_recursive<'a>(
|
||||||
&'a mut self,
|
&'a mut self,
|
||||||
context: &'a Context,
|
context: &'a Context,
|
||||||
@@ -135,12 +138,11 @@ impl HtmlMsgParser {
|
|||||||
}
|
}
|
||||||
MimeMultipartType::Single => {
|
MimeMultipartType::Single => {
|
||||||
let mimetype = mail.ctype.mimetype.parse::<Mime>()?;
|
let mimetype = mail.ctype.mimetype.parse::<Mime>()?;
|
||||||
if mimetype == mime::TEXT_HTML {
|
if mimetype == mime::TEXT_HTML && self.html.is_empty() {
|
||||||
if let Ok(decoded_data) = mail.get_body() {
|
if let Ok(decoded_data) = mail.get_body() {
|
||||||
self.html = decoded_data;
|
self.html = decoded_data;
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
} else if mimetype == mime::TEXT_PLAIN {
|
} else if mimetype == mime::TEXT_PLAIN && self.plain.is_none() {
|
||||||
if let Ok(decoded_data) = mail.get_body() {
|
if let Ok(decoded_data) = mail.get_body() {
|
||||||
self.plain = Some(PlainText {
|
self.plain = Some(PlainText {
|
||||||
text: decoded_data,
|
text: decoded_data,
|
||||||
@@ -155,7 +157,6 @@ impl HtmlMsgParser {
|
|||||||
false
|
false
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user