mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
fix threading in interation with non-delta-clients
threading was broken in core43 as this flags unencrypted messages as errors and errors are not replied-to. the fix is not to mark missing signatures for unencrypted messages as errors.
This commit is contained in:
@@ -127,69 +127,74 @@ impl MimeMessage {
|
|||||||
let mail_raw;
|
let mail_raw;
|
||||||
let mut gossipped_addr = Default::default();
|
let mut gossipped_addr = Default::default();
|
||||||
|
|
||||||
let (mail, signatures) = match e2ee::try_decrypt(context, &mail, message_time).await {
|
let (mail, signatures, warn_empty_signature) =
|
||||||
Ok((raw, signatures)) => {
|
match e2ee::try_decrypt(context, &mail, message_time).await {
|
||||||
if let Some(raw) = raw {
|
Ok((raw, signatures)) => {
|
||||||
// Encrypted, but maybe unsigned message. Only if
|
if let Some(raw) = raw {
|
||||||
// `signatures` set is non-empty, it is a valid
|
// Encrypted, but maybe unsigned message. Only if
|
||||||
// autocrypt message.
|
// `signatures` set is non-empty, it is a valid
|
||||||
|
// autocrypt message.
|
||||||
|
|
||||||
mail_raw = raw;
|
mail_raw = raw;
|
||||||
let decrypted_mail = mailparse::parse_mail(&mail_raw)?;
|
let decrypted_mail = mailparse::parse_mail(&mail_raw)?;
|
||||||
if std::env::var(crate::DCC_MIME_DEBUG).is_ok() {
|
if std::env::var(crate::DCC_MIME_DEBUG).is_ok() {
|
||||||
info!(context, "decrypted message mime-body:");
|
info!(context, "decrypted message mime-body:");
|
||||||
println!("{}", String::from_utf8_lossy(&mail_raw));
|
println!("{}", String::from_utf8_lossy(&mail_raw));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle any gossip headers if the mail was encrypted. See section
|
||||||
|
// "3.6 Key Gossip" of https://autocrypt.org/autocrypt-spec-1.1.0.pdf
|
||||||
|
// but only if the mail was correctly signed:
|
||||||
|
if !signatures.is_empty() {
|
||||||
|
let gossip_headers =
|
||||||
|
decrypted_mail.headers.get_all_values("Autocrypt-Gossip");
|
||||||
|
gossipped_addr = update_gossip_peerstates(
|
||||||
|
context,
|
||||||
|
message_time,
|
||||||
|
&mail,
|
||||||
|
gossip_headers,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
// let known protected headers from the decrypted
|
||||||
|
// part override the unencrypted top-level
|
||||||
|
|
||||||
|
// Signature was checked for original From, so we
|
||||||
|
// do not allow overriding it.
|
||||||
|
let mut throwaway_from = from.clone();
|
||||||
|
|
||||||
|
// We do not want to allow unencrypted subject in encrypted emails because the user might falsely think that the subject is safe.
|
||||||
|
// See https://github.com/deltachat/deltachat-core-rust/issues/1790.
|
||||||
|
headers.remove("subject");
|
||||||
|
|
||||||
|
MimeMessage::merge_headers(
|
||||||
|
context,
|
||||||
|
&mut headers,
|
||||||
|
&mut recipients,
|
||||||
|
&mut throwaway_from,
|
||||||
|
&mut chat_disposition_notification_to,
|
||||||
|
&decrypted_mail.headers,
|
||||||
|
);
|
||||||
|
|
||||||
|
(decrypted_mail, signatures, true)
|
||||||
|
} else {
|
||||||
|
// Message was not encrypted
|
||||||
|
(mail, signatures, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle any gossip headers if the mail was encrypted. See section
|
|
||||||
// "3.6 Key Gossip" of https://autocrypt.org/autocrypt-spec-1.1.0.pdf
|
|
||||||
// but only if the mail was correctly signed:
|
|
||||||
if !signatures.is_empty() {
|
|
||||||
let gossip_headers =
|
|
||||||
decrypted_mail.headers.get_all_values("Autocrypt-Gossip");
|
|
||||||
gossipped_addr =
|
|
||||||
update_gossip_peerstates(context, message_time, &mail, gossip_headers)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// let known protected headers from the decrypted
|
|
||||||
// part override the unencrypted top-level
|
|
||||||
|
|
||||||
// Signature was checked for original From, so we
|
|
||||||
// do not allow overriding it.
|
|
||||||
let mut throwaway_from = from.clone();
|
|
||||||
|
|
||||||
// We do not want to allow unencrypted subject in encrypted emails because the user might falsely think that the subject is safe.
|
|
||||||
// See https://github.com/deltachat/deltachat-core-rust/issues/1790.
|
|
||||||
headers.remove("subject");
|
|
||||||
|
|
||||||
MimeMessage::merge_headers(
|
|
||||||
context,
|
|
||||||
&mut headers,
|
|
||||||
&mut recipients,
|
|
||||||
&mut throwaway_from,
|
|
||||||
&mut chat_disposition_notification_to,
|
|
||||||
&decrypted_mail.headers,
|
|
||||||
);
|
|
||||||
|
|
||||||
(decrypted_mail, signatures)
|
|
||||||
} else {
|
|
||||||
// Message was not encrypted
|
|
||||||
(mail, signatures)
|
|
||||||
}
|
}
|
||||||
}
|
Err(err) => {
|
||||||
Err(err) => {
|
// continue with the current, still encrypted, mime tree.
|
||||||
// continue with the current, still encrypted, mime tree.
|
// unencrypted parts will be replaced by an error message
|
||||||
// unencrypted parts will be replaced by an error message
|
// that is added as "the message" to the chat then.
|
||||||
// that is added as "the message" to the chat then.
|
//
|
||||||
//
|
// if we just return here, the header is missing
|
||||||
// if we just return here, the header is missing
|
// and the caller cannot display the message
|
||||||
// and the caller cannot display the message
|
// and try to assign the message to a chat
|
||||||
// and try to assign the message to a chat
|
warn!(context, "decryption failed: {}", err);
|
||||||
warn!(context, "decryption failed: {}", err);
|
(mail, Default::default(), true)
|
||||||
(mail, Default::default())
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
let mut parser = MimeMessage {
|
let mut parser = MimeMessage {
|
||||||
parts: Vec::new(),
|
parts: Vec::new(),
|
||||||
@@ -215,7 +220,7 @@ impl MimeMessage {
|
|||||||
parser.heuristically_parse_ndn(context).await;
|
parser.heuristically_parse_ndn(context).await;
|
||||||
parser.parse_headers(context)?;
|
parser.parse_headers(context)?;
|
||||||
|
|
||||||
if parser.signatures.is_empty() {
|
if warn_empty_signature && parser.signatures.is_empty() {
|
||||||
for part in parser.parts.iter_mut() {
|
for part in parser.parts.iter_mut() {
|
||||||
part.error = "No valid signature".to_string();
|
part.error = "No valid signature".to_string();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user