diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b89e1ede..08df3e3e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - fix detection of "All mail", "Trash", "Junk" etc folders. #3760 - fetch messages sequentially to fix reactions on partially downloaded messages #3688 - Fix a bug where one malformed message blocked receiving any further messages #3769 +- strip leading/trailing whitespace from "Chat-Group-Name{,-Changed}:" headers content #3650 ## 1.101.0 diff --git a/python/tests/test_1_online.py b/python/tests/test_1_online.py index 85712af80..39cbae48c 100644 --- a/python/tests/test_1_online.py +++ b/python/tests/test_1_online.py @@ -405,6 +405,29 @@ def test_forward_own_message(acfactory, lp): assert msg_in.is_forwarded() +def test_long_group_name(acfactory, lp): + """See bug https://github.com/deltachat/deltachat-core-rust/issues/3650 "Space added before long + group names after MIME serialization/deserialization". + + When the mailadm bot creates a group with botadmin, the bot creates is as + "pytest-supportuser-282@x.testrun.org support group" (for example). But in the botadmin's + account object, the group chat is called " pytest-supportuser-282@x.testrun.org support group" + (with an additional space character in the beginning). + """ + ac1, ac2 = acfactory.get_online_accounts(2) + + lp.sec("ac1: creating group chat and sending a message") + group_name = "pytest-supportuser-282@x.testrun.org support group" + group = ac1.create_group_chat(group_name) + group.add_contact(ac2) + group.send_text("message") + + # wait for other account to receive + ev = ac2._evtracker.get_matching("DC_EVENT_INCOMING_MSG") + msg_in = ac2.get_message_by_id(ev.data2) + assert msg_in.chat.get_name() == group_name + + def test_send_self_message(acfactory, lp): ac1 = acfactory.new_online_configuring_account(mvbox_move=True) acfactory.bring_accounts_online() diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 76f7f1e4a..60f9a8e03 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -1510,7 +1510,10 @@ async fn create_or_lookup_group( let grpname = mime_parser .get_header(HeaderDef::ChatGroupName) - .context("Chat-Group-Name vanished")?; + .context("Chat-Group-Name vanished")? + // W/a for "Space added before long group names after MIME serialization/deserialization + // #3650" issue. DC itself never creates group names with leading/trailing whitespace. + .trim(); let new_chat_id = ChatId::create_multiuser_record( context, Chattype::Group, @@ -1618,9 +1621,15 @@ async fn apply_group_changes( { better_msg = Some(stock_str::msg_add_member(context, &added_member, from_id).await); recreate_member_list = true; - } else if let Some(old_name) = mime_parser.get_header(HeaderDef::ChatGroupNameChanged) { + } else if let Some(old_name) = mime_parser + .get_header(HeaderDef::ChatGroupNameChanged) + // See create_or_lookup_group() for explanation + .map(|s| s.trim()) + { if let Some(grpname) = mime_parser .get_header(HeaderDef::ChatGroupName) + // See create_or_lookup_group() for explanation + .map(|grpname| grpname.trim()) .filter(|grpname| grpname.len() < 200) { if chat_id