mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
Revert "mimeparser: assume all Thunderbird users prefer encryption" except for the test (#3778)
This partially reverts commit b341cfd4d9.
This commit is contained in:
@@ -5,7 +5,7 @@ use std::collections::HashSet;
|
|||||||
use anyhow::{Context as _, Result};
|
use anyhow::{Context as _, Result};
|
||||||
use mailparse::ParsedMail;
|
use mailparse::ParsedMail;
|
||||||
|
|
||||||
use crate::aheader::{Aheader, EncryptPreference};
|
use crate::aheader::Aheader;
|
||||||
use crate::authres::handle_authres;
|
use crate::authres::handle_authres;
|
||||||
use crate::authres::{self, DkimResults};
|
use crate::authres::{self, DkimResults};
|
||||||
use crate::contact::addr_cmp;
|
use crate::contact::addr_cmp;
|
||||||
@@ -61,7 +61,6 @@ pub(crate) async fn prepare_decryption(
|
|||||||
mail: &ParsedMail<'_>,
|
mail: &ParsedMail<'_>,
|
||||||
from: &str,
|
from: &str,
|
||||||
message_time: i64,
|
message_time: i64,
|
||||||
is_thunderbird: bool,
|
|
||||||
) -> Result<DecryptionInfo> {
|
) -> Result<DecryptionInfo> {
|
||||||
if mail.headers.get_header(HeaderDef::ListPost).is_some() {
|
if mail.headers.get_header(HeaderDef::ListPost).is_some() {
|
||||||
if mail.headers.get_header(HeaderDef::Autocrypt).is_some() {
|
if mail.headers.get_header(HeaderDef::Autocrypt).is_some() {
|
||||||
@@ -84,16 +83,10 @@ pub(crate) async fn prepare_decryption(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut autocrypt_header = Aheader::from_headers(from, &mail.headers)
|
let autocrypt_header = Aheader::from_headers(from, &mail.headers)
|
||||||
.ok_or_log_msg(context, "Failed to parse Autocrypt header")
|
.ok_or_log_msg(context, "Failed to parse Autocrypt header")
|
||||||
.flatten();
|
.flatten();
|
||||||
|
|
||||||
if is_thunderbird {
|
|
||||||
if let Some(autocrypt_header) = &mut autocrypt_header {
|
|
||||||
autocrypt_header.prefer_encrypt = EncryptPreference::Mutual;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let dkim_results = handle_authres(context, mail, from, message_time).await?;
|
let dkim_results = handle_authres(context, mail, from, message_time).await?;
|
||||||
|
|
||||||
let peerstate = get_autocrypt_peerstate(
|
let peerstate = get_autocrypt_peerstate(
|
||||||
|
|||||||
@@ -216,16 +216,9 @@ impl MimeMessage {
|
|||||||
headers.remove("secure-join-fingerprint");
|
headers.remove("secure-join-fingerprint");
|
||||||
headers.remove("chat-verified");
|
headers.remove("chat-verified");
|
||||||
|
|
||||||
let is_thunderbird = if let Some(user_agent) = headers.get("user-agent") {
|
|
||||||
info!(context, "Detected thunderbird");
|
|
||||||
user_agent.contains("Thunderbird")
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
};
|
|
||||||
|
|
||||||
let from = from.context("No from in message")?;
|
let from = from.context("No from in message")?;
|
||||||
let mut decryption_info =
|
let mut decryption_info =
|
||||||
prepare_decryption(context, &mail, &from.addr, message_time, is_thunderbird).await?;
|
prepare_decryption(context, &mail, &from.addr, message_time).await?;
|
||||||
|
|
||||||
// Memory location for a possible decrypted message.
|
// Memory location for a possible decrypted message.
|
||||||
let mut mail_raw = Vec::new();
|
let mut mail_raw = Vec::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user