diff --git a/src/receive_imf/receive_imf_tests.rs b/src/receive_imf/receive_imf_tests.rs index 618a807e7..c5dffdc79 100644 --- a/src/receive_imf/receive_imf_tests.rs +++ b/src/receive_imf/receive_imf_tests.rs @@ -5557,3 +5557,29 @@ async fn test_lookup_key_contact_by_address_self() -> Result<()> { ); Ok(()) } + +/// Tests reception of multipart/alternative +/// with three parts, one of which is a calendar. +/// +/// MS Exchange produces multipart/alternative +/// messages with three parts: +/// `text/plain`, `text/html` and `text/calendar`. +/// +/// We display `text/plain` part in this case. +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_calendar_alternative() -> Result<()> { + let mut tcm = TestContextManager::new(); + let t = &tcm.alice().await; + let raw = include_bytes!("../../test-data/message/calendar-alternative.eml"); + let msg = receive_imf(t, raw, false).await?.unwrap(); + assert_eq!(msg.msg_ids.len(), 1); + + let text_msg = Message::load_from_db(t, msg.msg_ids[0]).await?; + assert_eq!(text_msg.text, "Subject was here – Hello!"); + assert_eq!(text_msg.viewtype, Viewtype::Text); + assert!(text_msg.has_html()); + let html = text_msg.get_id().get_html(t).await.unwrap().unwrap(); + assert_eq!(html, "Hello!"); + + Ok(()) +} diff --git a/test-data/message/calendar-alternative.eml b/test-data/message/calendar-alternative.eml new file mode 100644 index 000000000..fce24e0dd --- /dev/null +++ b/test-data/message/calendar-alternative.eml @@ -0,0 +1,30 @@ +From: Bob +To: Alice +Subject: Subject was here +Date: Mon, 11 Aug 2025 10:15:52 +0000 +Message-ID: + +Content-Type: multipart/alternative; + boundary="_000_DU2PR10MB7741CB7551F025C98CE1B0C0EE28ADU2PR10MB7741EURP_" +MIME-Version: 1.0 + +--_000_DU2PR10MB7741CB7551F025C98CE1B0C0EE28ADU2PR10MB7741EURP_ +Content-Type: text/plain; charset="utf-8" + +Hello! +--_000_DU2PR10MB7741CB7551F025C98CE1B0C0EE28ADU2PR10MB7741EURP_ +Content-Type: text/html; charset="utf-8" + +Hello! +--_000_DU2PR10MB7741CB7551F025C98CE1B0C0EE28ADU2PR10MB7741EURP_ +Content-Type: text/calendar; charset="utf-8"; method=REQUEST + +BEGIN:VCALENDAR +METHOD:REQUEST +PRODID:Microsoft Exchange Server 2010 +VERSION:2.0 +... +END:VCALENDAR + +--_000_DU2PR10MB7741CB7551F025C98CE1B0C0EE28ADU2PR10MB7741EURP_-- +