Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
email_mirror: Improve filter_footer delimiter detection
Carlos Bederian1b517924598b
diff --git a/zerver/lib/email_mirror.py b/zerver/lib/email_mirror.pyindex bc51a695597..c387fc94b83 100644--- a/zerver/lib/email_mirror.py+++ b/zerver/lib/email_mirror.py@@ -322,7 +322,7 @@ def filter_footer(text: str) -> str:# isn't a trivial footer structure.return text- return text.partition("--")[0].strip()+ return re.split(r"^\s*--\s*$", text, 1, flags=re.MULTILINE)[0].strip()def extract_and_upload_attachments(message: EmailMessage, realm: Realm) -> str:diff --git a/zerver/tests/test_email_mirror.py b/zerver/tests/test_email_mirror.pyindex 3b106912853..a91d213825b 100644--- a/zerver/tests/test_email_mirror.py+++ b/zerver/tests/test_email_mirror.py@@ -211,10 +211,15 @@ class TestGetMissedMessageToken(ZulipTestCase):class TestFilterFooter(ZulipTestCase):def test_filter_footer(self) -> None:text = """Test message+ --Not a delimiter--+ More message--Footer"""+ expected_output = """Test message+ --Not a delimiter--+ More message"""result = filter_footer(text)- self.assertEqual(result, "Test message")+ self.assertEqual(result, expected_output)def test_filter_footer_many_parts(self) -> None:text = """Test message