mirror of https://github.com/zulip/zulip.git
email_mirror: Improve filter_footer delimiter detection
This commit is contained in:
parent
06c0a29e47
commit
1b51792459
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue