mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 21:36:29 +03:00
dc_receive_imf: don't fail on invalid address in the To field
This is an irrecoverable error, dc_receive_imf must not fail on it as it prevents last seen UID from advancing, so the same message is prefetched on each iteration of IMAP loop.
This commit is contained in:
@@ -17,7 +17,9 @@ use crate::constants::{
|
||||
Blocked, Chattype, ShowEmails, Viewtype, DC_CHAT_ID_TRASH, DC_CONTACT_ID_LAST_SPECIAL,
|
||||
DC_CONTACT_ID_SELF,
|
||||
};
|
||||
use crate::contact::{addr_cmp, normalize_name, Contact, Origin, VerifiedStatus};
|
||||
use crate::contact::{
|
||||
addr_cmp, may_be_valid_addr, normalize_name, Contact, Origin, VerifiedStatus,
|
||||
};
|
||||
use crate::context::Context;
|
||||
use crate::dc_tools::{dc_extract_grpid_from_rfc724_mid, dc_smeared_time};
|
||||
use crate::download::DownloadState;
|
||||
@@ -2284,14 +2286,17 @@ async fn dc_add_or_lookup_contacts_by_address_list(
|
||||
) -> Result<Vec<u32>> {
|
||||
let mut contact_ids = BTreeSet::new();
|
||||
for info in address_list.iter() {
|
||||
let addr = &info.addr;
|
||||
if !may_be_valid_addr(addr) {
|
||||
continue;
|
||||
}
|
||||
let display_name = if prevent_rename {
|
||||
Some("")
|
||||
} else {
|
||||
info.display_name.as_deref()
|
||||
};
|
||||
contact_ids.insert(
|
||||
add_or_lookup_contact_by_addr(context, display_name, &info.addr, origin).await?,
|
||||
);
|
||||
contact_ids
|
||||
.insert(add_or_lookup_contact_by_addr(context, display_name, addr, origin).await?);
|
||||
}
|
||||
|
||||
Ok(contact_ids.into_iter().collect::<Vec<u32>>())
|
||||
@@ -4989,4 +4994,16 @@ Message with references."#;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
async fn test_invalid_to_address() -> Result<()> {
|
||||
let alice = TestContext::new_alice().await;
|
||||
|
||||
let mime = include_bytes!("../test-data/message/invalid_email_to.eml");
|
||||
|
||||
// dc_receive_imf should not fail on this mail with invalid To: field
|
||||
dc_receive_imf(&alice, mime, "Inbox", false).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
15
test-data/message/invalid_email_to.eml
Normal file
15
test-data/message/invalid_email_to.eml
Normal file
@@ -0,0 +1,15 @@
|
||||
Subject: Some subject
|
||||
Date: Sat, 01 Jan 2022 21:14:26 +0000
|
||||
Chat-Version: 1.0
|
||||
MIME-Version: 1.0
|
||||
Message-ID: <foo@example.org>
|
||||
To: <alice@example.org>, <bob@example.net>,
|
||||
<xxxxxxxx.xxxx@example.orgã£â£ã¢â£ã£â¢ã¢â£ã£â£ã¢â¢ã£â¢ã¢â£ã£â£ã¢â£ã£â¢ã¢â¢ã£â£ã¢â¢ã£â¢ã¢â£ã£â£ã¢â£ã£â¢ã¢â£ã£â£ã¢â¢ã£â¢ã¢â¢ã£â£ã¢â£ã£â¢ã¢â¢ã£â£ã¢â¢ã£â¢ã¢â°ã£â£ã¢â£ã£â¢ã¢â£ã£â£ã¢â¢ã£â¢ã¢â£ã£â£ã¢â£ã£â¢ã¢â¢ã£â£ã¢â¢ã£â¢ã¢â¢ã£â£ã¢â£ã£â¢ã¢â£ã£â£ã¢â¢ã£â¢ã¢â¢ã£â£ã¢â£ã£â¢ã¢â¢ã£â£ã¢â¢ã£â¢ã¢âã£â£ã¢â£ã£â¢ã¢â£ã£â£ã¢â¢ã£â¢ã¢â£ã£â£ã¢â£ã£â¢ã¢â¢ã£â£ã¢â¢ã£â¢ã¢â¢ã£â£ã¢â£ã£â¢ã¢â£ã£â£ã¢â¢ã£â¢ã¢â¢ã£â£ã¢â£ã£â¢ã¢â¢ã£â£ã¢â¢ã£â¢ã¢â¦ã£â£ã¢â£ã£â¢ã¢â£ã£â£ã¢â¢ã£â¢ã¢â£ã£â£ã¢â£ã£â¢ã¢â¢ã£â£ã¢â¢ã£â¢ã¢â¢ã£â£ã¢â£ã£â¢ã¢â£ã£â£ã¢â¢ã
|
||||
£â¢ã<C2A2>,
|
||||
<20>â¢ã£â£ã¢â£ã£â¢ã¢â¢ã£â£ã¢â¢ã£â¢ã¢â<C2A2><EFBFBD>@abcdef.example.net,
|
||||
<tmp.xxxxx@testrun.org>
|
||||
From: Claire <claire@example.org>
|
||||
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=no
|
||||
X-Spam: Yes
|
||||
|
||||
Some message.
|
||||
Reference in New Issue
Block a user