From ac72280e691ecb732bbea7c841e0e4f7e2d5e3f5 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Fri, 7 Aug 2020 23:17:08 +0300 Subject: [PATCH 01/11] =?UTF-8?q?Hide=20SIJ=C3=9A=20messenger=20footer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dc_receive_imf.rs | 4 ++-- src/mimeparser.rs | 11 ++++------- src/simplify.rs | 12 +++++++++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 7d0100a23..65cc13378 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -2475,7 +2475,7 @@ mod tests { "haeclirth.sinoenrat@yahoo.com", "1680295672.3657931.1591783872936@mail.yahoo.com", include_bytes!("../test-data/message/yahoo_ndn.eml"), - "Failure Notice – Sorry, we were unable to deliver your message to the following address.\n\n:\n554: delivery error: dd Not a valid recipient - atlas117.free.mail.ne1.yahoo.com" + "Failure Notice – Sorry, we were unable to deliver your message to the following address.\n\n:\n554: delivery error: dd Not a valid recipient - atlas117.free.mail.ne1.yahoo.com [...]" ) .await; } @@ -2499,7 +2499,7 @@ mod tests { "snaerituhaeirns@gmail.com", "9c9c2a32-056b-3592-c372-d7e8f0bd4bc2@gmx.de", include_bytes!("../test-data/message/gmx_ndn.eml"), - "Mail delivery failed: returning message to sender – This message was created automatically by mail delivery software.\n\nA message that you sent could not be delivered to one or more of\nits recipients. This is a permanent error. The following address(es)\nfailed:\n\nsnaerituhaeirns@gmail.com:\nSMTP error from remote server for RCPT TO command, host: gmail-smtp-in.l.google.com (66.102.1.27) reason: 550-5.1.1 The email account that you tried to reach does not exist. Please\n try\n550-5.1.1 double-checking the recipient\'s email address for typos or\n550-5.1.1 unnecessary spaces. Learn more at\n550 5.1.1 https://support.google.com/mail/?p=NoSuchUser f6si2517766wmc.21\n9 - gsmtp" + "Mail delivery failed: returning message to sender – This message was created automatically by mail delivery software.\n\nA message that you sent could not be delivered to one or more of\nits recipients. This is a permanent error. The following address(es)\nfailed:\n\nsnaerituhaeirns@gmail.com:\nSMTP error from remote server for RCPT TO command, host: gmail-smtp-in.l.google.com (66.102.1.27) reason: 550-5.1.1 The email account that you tried to reach does not exist. Please\n try\n550-5.1.1 double-checking the recipient\'s email address for typos or\n550-5.1.1 unnecessary spaces. Learn more at\n550 5.1.1 https://support.google.com/mail/?p=NoSuchUser f6si2517766wmc.21\n9 - gsmtp [...]" ) .await; } diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 66c875e06..7016e743c 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -1007,13 +1007,10 @@ impl MimeMessage { } if let Some(failure_report) = &self.failure_report { - let error = parts.iter().find(|p| p.typ == Viewtype::Text).map(|p| { - let msg = &p.msg; - msg.find("\n--- ") - .and_then(|footer_start| msg.get(..footer_start)) - .unwrap_or(msg) - .trim() - }); + let error = parts + .iter() + .find(|p| p.typ == Viewtype::Text) + .map(|p| p.msg.clone()); message::handle_ndn(context, failure_report, error).await } } diff --git a/src/simplify.rs b/src/simplify.rs index 98c66a74e..88c613835 100644 --- a/src/simplify.rs +++ b/src/simplify.rs @@ -46,9 +46,7 @@ fn remove_message_footer<'a>(lines: &'a [&str]) -> &'a [&'a str] { fn remove_nonstandard_footer<'a>(lines: &'a [&str]) -> (&'a [&'a str], bool) { for (ix, &line) in lines.iter().enumerate() { if line == "--" - || line == "---" - || line == "----" - || line.starts_with("-----") + || line.starts_with("---") || line.starts_with("_____") || line.starts_with("=====") || line.starts_with("*****") @@ -336,9 +334,17 @@ mod tests { let (plain, _) = simplify(escaped, true); assert_eq!(plain, "text\n\n--\ntreated as footer when unescaped"); + // Nonstandard footer sent by https://siju.es/ + let input = "Message text here\n---Desde mi teléfono con SIJÚ\n\nQuote here".to_string(); + let (plain, _) = simplify(input.clone(), false); + assert_eq!(plain, "Message text here [...]"); + let (plain, _) = simplify(input.clone(), true); + assert_eq!(plain, input); + let input = "--\ntreated as footer when unescaped".to_string(); let (plain, _) = simplify(input.clone(), true); assert_eq!(plain, ""); // see remove_message_footer() for some explanations + let escaped = escape_message_footer_marks(&input); let (plain, _) = simplify(escaped, true); assert_eq!(plain, "--\ntreated as footer when unescaped"); From 2c41b3f3e0daabcf404600e241094f13c4e732ce Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 8 Aug 2020 04:32:12 +0300 Subject: [PATCH 02/11] Always translate EphemeralTimerChanged message An EphemeralTimerChanged message with the same timer as already set can be received when there are large delays or lost messages. Even though inner_set_ephemeral_timer should not be called in this case, because it emits an event indicating timer change, system message will be added to the chat, so it should be translated with set_better_msg in any case. --- src/dc_receive_imf.rs | 57 ++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 7d0100a23..77a9e3623 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -663,42 +663,39 @@ async fn add_parts( && !is_mdn && (*chat_id).get_ephemeral_timer(context).await? != ephemeral_timer { - match (*chat_id) + if let Err(err) = (*chat_id) .inner_set_ephemeral_timer(context, ephemeral_timer) .await { - Ok(()) => { - if mime_parser.is_system_message == SystemMessage::EphemeralTimerChanged { - set_better_msg( - mime_parser, - stock_ephemeral_timer_changed(context, ephemeral_timer, from_id).await, - ); - - // Do not delete the system message itself. - // - // This prevents confusion when timer is changed - // to 1 week, and then changed to 1 hour: after 1 - // hour, only the message about the change to 1 - // week is left. - ephemeral_timer = EphemeralTimer::Disabled; - } else { - chat::add_info_msg( - context, - *chat_id, - stock_ephemeral_timer_changed(context, ephemeral_timer, from_id).await, - ) - .await; - } - } - Err(err) => { - warn!( - context, - "failed to modify timer for chat {}: {}", chat_id, err - ); - } + warn!( + context, + "failed to modify timer for chat {}: {}", chat_id, err + ); + } else if mime_parser.is_system_message != SystemMessage::EphemeralTimerChanged { + chat::add_info_msg( + context, + *chat_id, + stock_ephemeral_timer_changed(context, ephemeral_timer, from_id).await, + ) + .await; } } + if mime_parser.is_system_message == SystemMessage::EphemeralTimerChanged { + set_better_msg( + mime_parser, + stock_ephemeral_timer_changed(context, ephemeral_timer, from_id).await, + ); + + // Do not delete the system message itself. + // + // This prevents confusion when timer is changed + // to 1 week, and then changed to 1 hour: after 1 + // hour, only the message about the change to 1 + // week is left. + ephemeral_timer = EphemeralTimer::Disabled; + } + // correct message_timestamp, it should not be used before, // however, we cannot do this earlier as we need from_id to be set let in_fresh = state == MessageState::InFresh; From 801b9f3ffa08eb0d4709f9714731d6bc2519bfc0 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Fri, 7 Aug 2020 00:53:26 +0300 Subject: [PATCH 03/11] Fix dc_chat_get_remaining_mute_duration Return time since current time, not UNIX epoch. --- deltachat-ffi/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index af0e5c757..0a1768c7c 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -2445,7 +2445,7 @@ pub unsafe extern "C" fn dc_chat_get_remaining_mute_duration(chat: *mut dc_chat_ MuteDuration::NotMuted => 0, MuteDuration::Forever => -1, MuteDuration::Until(when) => when - .duration_since(SystemTime::UNIX_EPOCH) + .duration_since(SystemTime::now()) .map(|d| d.as_secs() as i64) .unwrap_or(0), } From da5796e8a629192ced2bf00a75b5ef5f7a698435 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Fri, 7 Aug 2020 00:53:48 +0300 Subject: [PATCH 04/11] Fix python bindings call to dc_chat_get_remaining_mute_duration --- python/src/deltachat/chat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/src/deltachat/chat.py b/python/src/deltachat/chat.py index 54a7ede0b..60860d5a3 100644 --- a/python/src/deltachat/chat.py +++ b/python/src/deltachat/chat.py @@ -137,7 +137,7 @@ class Chat(object): :param duration: :returns: Returns the number of seconds the chat is still muted for. (0 for not muted, -1 forever muted) """ - return bool(lib.dc_chat_get_remaining_mute_duration(self.id)) + return lib.dc_chat_get_remaining_mute_duration(self._dc_chat) def get_ephemeral_timer(self): """ get ephemeral timer. From 6d68fd4500c9a6e6ff3965fdb0b4f5ca29bf0b2f Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Fri, 7 Aug 2020 00:54:00 +0300 Subject: [PATCH 05/11] python: test get_mute_duration() --- python/tests/test_account.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/tests/test_account.py b/python/tests/test_account.py index c15fe4b5b..6b016b20e 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -276,12 +276,15 @@ class TestOfflineChat: def test_mute(self, ac1): chat = ac1.create_group_chat(name="title1") assert not chat.is_muted() + assert chat.get_mute_duration() == 0 chat.mute() assert chat.is_muted() + assert chat.get_mute_duration() == -1 chat.unmute() assert not chat.is_muted() chat.mute(50) assert chat.is_muted() + assert chat.get_mute_duration() <= 50 with pytest.raises(ValueError): chat.mute(-51) From 24d0382ec33a8b750cd624114f6138300646a115 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Fri, 7 Aug 2020 00:54:16 +0300 Subject: [PATCH 06/11] Add regression test for dc_set_chat_mute_duration panic Panic was fixed in 3c8e60a2a305d96d8082faf7332f1d3f0485c437 --- python/tests/test_account.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 6b016b20e..4757d8fe6 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -288,6 +288,11 @@ class TestOfflineChat: with pytest.raises(ValueError): chat.mute(-51) + # Regression test, this caused Rust panic previously + chat.mute(2**63 - 1) + assert chat.is_muted() + assert chat.get_mute_duration() == -1 + def test_delete_and_send_fails(self, ac1, chat1): chat1.delete() ac1._evtracker.wait_next_messages_changed() From 9a21d5e9d9fc5088b0bbbd23aaf6126915994474 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 8 Aug 2020 17:35:07 +0300 Subject: [PATCH 07/11] Second attempt to fix flaky test The server sometimes reorders the messages even if they were accepted strictly in sequence. --- python/tests/test_account.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 4757d8fe6..a2a7d8980 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -1669,15 +1669,11 @@ class TestOnlineAccount: for text in texts: chat12.send_text(text) - # Ensure messages are delivered in exactly this order. - ac1._evtracker.get_matching("DC_EVENT_SMTP_MESSAGE_SENT") - ac1._evtracker.get_matching("DC_EVENT_MSG_DELIVERED") - lp.sec("ac2: waiting for all messages on the other side") to_delete = [] for text in texts: msg = ac2._evtracker.wait_next_incoming_message() - assert msg.text == text + assert msg.text in texts if text != "third": to_delete.append(msg) From 4f8e7e0166bdab98f943d389fb28f88019ca8daa Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 8 Aug 2020 23:03:59 +0300 Subject: [PATCH 08/11] python: fix more flaky tests This change fixes test_immediate_autodelete and maybe other tests using DirectImap.get_all_messages(). --- python/src/deltachat/direct_imap.py | 9 +++++++++ python/tests/test_account.py | 8 -------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/python/src/deltachat/direct_imap.py b/python/src/deltachat/direct_imap.py index 2d86b9754..c4c118486 100644 --- a/python/src/deltachat/direct_imap.py +++ b/python/src/deltachat/direct_imap.py @@ -108,6 +108,15 @@ class DirectImap: def get_all_messages(self): assert not self._idling + + # Flush unsolicited responses. IMAPClient has problems + # dealing with them: https://github.com/mjs/imapclient/issues/334 + # When this NOOP was introduced, next FETCH returned empty + # result instead of a single message, even though IMAP server + # can only return more untagged responses than required, not + # less. + self.conn.noop() + return self.conn.fetch(ALL, [FLAGS]) def get_unread_messages(self): diff --git a/python/tests/test_account.py b/python/tests/test_account.py index a2a7d8980..22b7e3539 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -1688,14 +1688,6 @@ class TestOnlineAccount: lp.sec("imap2: test that only one message is left") imap2 = ac2.direct_imap - # Flush unsolicited responses. IMAPClient has problems - # dealing with them: https://github.com/mjs/imapclient/issues/334 - # When this NOOP was introduced, next FETCH returned empty - # result instead of a single message, even though IMAP server - # can only return more untagged responses than required, not - # less. - imap2.conn.noop() - assert len(imap2.get_all_messages()) == 1 From ffd6877243053e783e9281395f06024bc0a9abeb Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sat, 8 Aug 2020 13:02:31 +0200 Subject: [PATCH 09/11] update changelog for 1.44 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05624f429..a8dc2ec7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 1.44.0 + +- fix peerstate issues #1800 #1805 + +- more bug fixes #1802 #1803 #1806 #1807 #1810 #1813 #1812 + + ## 1.43.0 - improve using own jitsi-servers #1785 From fa795c54df37838ef833529e0d4cfb75c57c3e6e Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sat, 8 Aug 2020 13:03:19 +0200 Subject: [PATCH 10/11] bump version to 1.44.0 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- deltachat-ffi/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 10fda6690..68b08bea6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -790,7 +790,7 @@ dependencies = [ [[package]] name = "deltachat" -version = "1.43.0" +version = "1.44.0" dependencies = [ "ansi_term 0.12.1", "anyhow", @@ -861,7 +861,7 @@ dependencies = [ [[package]] name = "deltachat_ffi" -version = "1.43.0" +version = "1.44.0" dependencies = [ "anyhow", "async-std", diff --git a/Cargo.toml b/Cargo.toml index 2e514400a..025a92291 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "deltachat" -version = "1.43.0" +version = "1.44.0" authors = ["Delta Chat Developers (ML) "] edition = "2018" license = "MPL-2.0" diff --git a/deltachat-ffi/Cargo.toml b/deltachat-ffi/Cargo.toml index 1af522bc2..7f10d5e00 100644 --- a/deltachat-ffi/Cargo.toml +++ b/deltachat-ffi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "deltachat_ffi" -version = "1.43.0" +version = "1.44.0" description = "Deltachat FFI" authors = ["Delta Chat Developers (ML) "] edition = "2018" From 8b22f74fa654cda59840d1da3ba1b4c1077fa567 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 8 Aug 2020 17:48:24 +0300 Subject: [PATCH 11/11] Expand changelog --- CHANGELOG.md | 16 +++++++++++++++- python/CHANGELOG | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8dc2ec7b..b01a565ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,21 @@ - fix peerstate issues #1800 #1805 -- more bug fixes #1802 #1803 #1806 #1807 #1810 #1813 #1812 +- fix a crash related to muted chats #1803 + +- fix incorrect dimensions sometimes reported for images #1806 + +- fixed `dc_chat_get_remaining_mute_duration` function #1807 + +- handle empty tags (e.g. `
`) in HTML mails #1810 + +- always translate the message about disappearing messages timer change #1813 + +- improve footer detection in plain text email #1812 + +- update device chat icon to fix warnings in iOS logs #1802 + +- fix deletion of multiple messages #1795 ## 1.43.0 diff --git a/python/CHANGELOG b/python/CHANGELOG index 5190bfab4..6ef1f434e 100644 --- a/python/CHANGELOG +++ b/python/CHANGELOG @@ -1,3 +1,8 @@ +1.44.0 +------ + +- fix Chat.get_mute_duration() + 1.40.1 ---------------