Skip to content

Commit cf85e20

Browse files
committed
fixup: download legacy Secure-Join messages even if encryption is enforced
1 parent c40e4c4 commit cf85e20

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/imap.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,12 +1994,15 @@ pub(crate) async fn prefetch_should_download(
19941994
// prevent_rename=true as this might be a mailing list message and in this case it would be bad if we rename the contact.
19951995
// (prevent_rename is the last argument of from_field_to_contact_id())
19961996

1997-
let is_encrypted = if let Some(content_type) = headers.get_header_value(HeaderDef::ContentType)
1998-
{
1999-
mailparse::parse_content_type(&content_type).mimetype == "multipart/encrypted"
2000-
} else {
2001-
false
2002-
};
1997+
// New SecureJoin is fully encrypted,
1998+
// but for compatibility we still download legacy `Secure-Join: vc-request` messages.
1999+
let is_legacy_securejoin = headers.get_header_value(HeaderDef::SecureJoin).is_some();
2000+
2001+
let is_encrypted = headers
2002+
.get_header_value(HeaderDef::ContentType)
2003+
.is_some_and(|content_type| {
2004+
mailparse::parse_content_type(&content_type).mimetype == "multipart/encrypted"
2005+
});
20032006

20042007
if flags.any(|f| f == Flag::Draft) {
20052008
info!(context, "Ignoring draft message");
@@ -2008,7 +2011,9 @@ pub(crate) async fn prefetch_should_download(
20082011

20092012
let should_download = maybe_ndn
20102013
|| (!blocked_contact
2011-
&& (is_encrypted || !context.get_config_bool(Config::ForceEncryption).await?));
2014+
&& (is_legacy_securejoin
2015+
|| is_encrypted
2016+
|| !context.get_config_bool(Config::ForceEncryption).await?));
20122017
Ok(should_download)
20132018
}
20142019

src/imap/session.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const PREFETCH_FLAGS: &str = "(UID RFC822.SIZE BODY.PEEK[HEADER.FIELDS (\
2222
X-MICROSOFT-ORIGINAL-MESSAGE-ID \
2323
FROM \
2424
CONTENT-TYPE \
25+
SECURE-JOIN \
2526
CHAT-VERSION \
2627
CHAT-IS-POST-MESSAGE \
2728
AUTOCRYPT-SETUP-MESSAGE\

0 commit comments

Comments
 (0)