From 5bdc3cefb72b694d8357ff4f7c8325ee2407bc10 Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 15 May 2023 19:44:41 +0000 Subject: [PATCH] fix: handle quote marks in the List-Id when setting chat name --- src/receive_imf/tests.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/receive_imf/tests.rs b/src/receive_imf/tests.rs index 1fda38221..444dbd034 100644 --- a/src/receive_imf/tests.rs +++ b/src/receive_imf/tests.rs @@ -1058,6 +1058,30 @@ async fn test_mailing_list_multiple_names_in_subject() -> Result<()> { Ok(()) } +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_mailing_list_with_quotes() -> Result<()> { + let t = TestContext::new_alice().await; + receive_imf( + &t, + b"From: Foo Bar \n\ + To: Alice \n\ + Subject: confirm xxyyzz\n\ + Message-ID: <3333@example.org>\n\ + List-Id: \"Mailing list for \\\"Foo Bar\\\"\"\n\ + \t\n\ + Date: Sun, 22 Mar 2020 22:37:57 +0000\n\ + \n\ + hello\n", + false, + ) + .await?; + let msg = t.get_last_msg().await; + let chat_id = msg.get_chat_id(); + let chat = Chat::load_from_db(&t, chat_id).await?; + assert_eq!(chat.name, "Mailing list for \"Foo Bar\""); + Ok(()) +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_majordomo_mailing_list() -> Result<()> { let t = TestContext::new_alice().await;