mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 12:56:30 +03:00
feat: do not use format=flowed in outgoing messages (#6256)
Text parts are using quoted-printable encoding which takes care of wrapping long lines, so using format=flowed is unnecessary. This improves compatibility with receivers which do not support format=flowed. Receiving format=flowed messages is still possible, receiver side of Delta Chat is unchanged.
This commit is contained in:
@@ -6,7 +6,6 @@ use anyhow::{bail, Context as _, Result};
|
|||||||
use base64::Engine as _;
|
use base64::Engine as _;
|
||||||
use chrono::TimeZone;
|
use chrono::TimeZone;
|
||||||
use email::Mailbox;
|
use email::Mailbox;
|
||||||
use format_flowed::{format_flowed, format_flowed_quote};
|
|
||||||
use lettre_email::{Address, Header, MimeMultipartType, PartBuilder};
|
use lettre_email::{Address, Header, MimeMultipartType, PartBuilder};
|
||||||
use tokio::fs;
|
use tokio::fs;
|
||||||
|
|
||||||
@@ -1300,9 +1299,18 @@ impl MimeFactory {
|
|||||||
|
|
||||||
let final_text = placeholdertext.as_deref().unwrap_or(&msg.text);
|
let final_text = placeholdertext.as_deref().unwrap_or(&msg.text);
|
||||||
|
|
||||||
let mut quoted_text = msg
|
let mut quoted_text = None;
|
||||||
.quoted_text()
|
if let Some(msg_quoted_text) = msg.quoted_text() {
|
||||||
.map(|quote| format_flowed_quote("e) + "\r\n\r\n");
|
let mut some_quoted_text = String::new();
|
||||||
|
for quoted_line in msg_quoted_text.split('\n') {
|
||||||
|
some_quoted_text += "> ";
|
||||||
|
some_quoted_text += quoted_line;
|
||||||
|
some_quoted_text += "\r\n";
|
||||||
|
}
|
||||||
|
some_quoted_text += "\r\n";
|
||||||
|
quoted_text = Some(some_quoted_text)
|
||||||
|
}
|
||||||
|
|
||||||
if !is_encrypted && msg.param.get_bool(Param::ProtectQuote).unwrap_or_default() {
|
if !is_encrypted && msg.param.get_bool(Param::ProtectQuote).unwrap_or_default() {
|
||||||
// Message is not encrypted but quotes encrypted message.
|
// Message is not encrypted but quotes encrypted message.
|
||||||
quoted_text = Some("> ...\r\n\r\n".to_string());
|
quoted_text = Some("> ...\r\n\r\n".to_string());
|
||||||
@@ -1312,7 +1320,6 @@ impl MimeFactory {
|
|||||||
// Delta Chat.
|
// Delta Chat.
|
||||||
quoted_text = Some("\r\n".to_string());
|
quoted_text = Some("\r\n".to_string());
|
||||||
}
|
}
|
||||||
let flowed_text = format_flowed(final_text);
|
|
||||||
|
|
||||||
let is_reaction = msg.param.get_int(Param::Reaction).unwrap_or_default() != 0;
|
let is_reaction = msg.param.get_int(Param::Reaction).unwrap_or_default() != 0;
|
||||||
|
|
||||||
@@ -1322,7 +1329,7 @@ impl MimeFactory {
|
|||||||
"{}{}{}{}{}{}",
|
"{}{}{}{}{}{}",
|
||||||
fwdhint.unwrap_or_default(),
|
fwdhint.unwrap_or_default(),
|
||||||
quoted_text.unwrap_or_default(),
|
quoted_text.unwrap_or_default(),
|
||||||
escape_message_footer_marks(&flowed_text),
|
escape_message_footer_marks(final_text),
|
||||||
if !final_text.is_empty() && !footer.is_empty() {
|
if !final_text.is_empty() && !footer.is_empty() {
|
||||||
"\r\n\r\n"
|
"\r\n\r\n"
|
||||||
} else {
|
} else {
|
||||||
@@ -1332,10 +1339,8 @@ impl MimeFactory {
|
|||||||
footer
|
footer
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut main_part = PartBuilder::new().header((
|
let mut main_part =
|
||||||
"Content-Type",
|
PartBuilder::new().header(("Content-Type", "text/plain; charset=utf-8"));
|
||||||
"text/plain; charset=utf-8; format=flowed; delsp=no",
|
|
||||||
));
|
|
||||||
main_part = self.add_message_text(main_part, message_text);
|
main_part = self.add_message_text(main_part, message_text);
|
||||||
|
|
||||||
if is_reaction {
|
if is_reaction {
|
||||||
|
|||||||
@@ -1068,7 +1068,7 @@ async fn test_classic_mailing_list() -> Result<()> {
|
|||||||
let mime = sent.payload();
|
let mime = sent.payload();
|
||||||
|
|
||||||
println!("Sent mime message is:\n\n{mime}\n\n");
|
println!("Sent mime message is:\n\n{mime}\n\n");
|
||||||
assert!(mime.contains("Content-Type: text/plain; charset=utf-8; format=flowed; delsp=no\r\n"));
|
assert!(mime.contains("Content-Type: text/plain; charset=utf-8\r\n"));
|
||||||
assert!(mime.contains("Subject: =?utf-8?q?Re=3A_=5Bdelta-dev=5D_What=27s_up=3F?=\r\n"));
|
assert!(mime.contains("Subject: =?utf-8?q?Re=3A_=5Bdelta-dev=5D_What=27s_up=3F?=\r\n"));
|
||||||
assert!(mime.contains("MIME-Version: 1.0\r\n"));
|
assert!(mime.contains("MIME-Version: 1.0\r\n"));
|
||||||
assert!(mime.contains("In-Reply-To: <38942@posteo.org>\r\n"));
|
assert!(mime.contains("In-Reply-To: <38942@posteo.org>\r\n"));
|
||||||
|
|||||||
Reference in New Issue
Block a user