From 3c34096392ca81d7ce498a7b96cd374748e121c7 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 22 Mar 2020 17:21:31 +0100 Subject: [PATCH 1/2] add a failing test that crashes when sending a message to a self-only group with bcc_self enabled --- python/tests/test_account.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 71c8322d3..31835b152 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -76,6 +76,20 @@ class TestOfflineAccountBasic: with pytest.raises(KeyError): ac1.get_config("123123") + def test_empty_group_bcc_self_enabled(self, acfactory): + ac1 = acfactory.get_configured_offline_account() + ac1.set_config("bcc_self", "1") + chat = ac1.create_group_chat(name="group1") + msg = chat.send_text("msg1") + assert msg in chat.get_messages() + + def test_empty_group_bcc_self_disabled(self, acfactory): + ac1 = acfactory.get_configured_offline_account() + ac1.set_config("bcc_self", "0") + chat = ac1.create_group_chat(name="group1") + msg = chat.send_text("msg1") + assert msg in chat.get_messages() + class TestOfflineContact: def test_contact_attr(self, acfactory): From 17ff1ab3729bdb1d0d9184bdbf0ecbfc21848dcd Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 23 Mar 2020 01:48:27 +0100 Subject: [PATCH 2/2] this corrects the To:-list for group-messages with only SELF as member. before, the list was empty and trying to send to groups that only contain SELF lead to a crash. in theory, this happens for both, bcc_self enabled or not, however, if bcc_self was disabled (default setting), things worked as the whole mimerendering was skipped on a higher level. also, the saved-messages-chat was not affected as this was checked explicitly. this pr changes the mimerendering so that From: is used as To: if there is no recipient-list and the messasge will be sent to SELF only. --- src/mimefactory.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mimefactory.rs b/src/mimefactory.rs index 2c6a56842..4e957c58c 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -368,7 +368,7 @@ impl<'a, 'b> MimeFactory<'a, 'b> { self.from_addr.clone(), ); - let mut to = Vec::with_capacity(self.recipients.len()); + let mut to = Vec::new(); for (name, addr) in self.recipients.iter() { if name.is_empty() { to.push(Address::new_mailbox(addr.clone())); @@ -380,6 +380,10 @@ impl<'a, 'b> MimeFactory<'a, 'b> { } } + if to.is_empty() { + to.push(from.clone()); + } + if !self.references.is_empty() { unprotected_headers.push(Header::new("References".into(), self.references.clone())); }