diff --git a/zerver/fixtures/slack_message_conversion.json b/zerver/fixtures/slack_message_conversion.json
index 221ba2407f..1239ac7bb5 100644
--- a/zerver/fixtures/slack_message_conversion.json
+++ b/zerver/fixtures/slack_message_conversion.json
@@ -15,6 +15,16 @@
"input": " this is a good website.",
"conversion_output": "http://datausa.io/ this is a good website."
},
+ {
+ "name": "mailto_format1",
+ "input": "email me at ",
+ "conversion_output": "email me at mailto:random@gmail.com"
+ },
+ {
+ "name": "mailto_format2",
+ "input": "email me at ",
+ "conversion_output": "email me at mailto:random@gmail.com"
+ },
{
"name": "valid_strikethrough_test",
"input": "(~str ike!~, text. ~Also ~)",
diff --git a/zerver/lib/slack_message_conversion.py b/zerver/lib/slack_message_conversion.py
index 80b7c3eb12..b9dfc7677b 100644
--- a/zerver/lib/slack_message_conversion.py
+++ b/zerver/lib/slack_message_conversion.py
@@ -15,6 +15,14 @@ LINK_REGEX = r"""
(\|)?(?:\|([^>]+))? # char after pipe (for slack links)
(>)
"""
+
+SLACK_MAILTO_REGEX = r"""
+ <((mailto:)? # match ` # match email
+ """
+
SLACK_USERMENTION_REGEX = r"""
(<@) # Start with '<@'
([a-zA-Z0-9]+) # Here we have the Slack id
@@ -83,6 +91,8 @@ def convert_to_zulip_markdown(text: str, users: List[ZerverFieldsT],
# Check and convert link format
text, has_link = convert_link_format(text)
+ # convert `` to `mailto:foo@foo.com`
+ text, has_link = convert_mailto_format(text)
return text, mentioned_users_id, has_link
@@ -126,3 +136,14 @@ def convert_link_format(text: str) -> Tuple[str, bool]:
has_link = True
text = text.replace(match.group(0), converted_text)
return text, has_link
+
+def convert_mailto_format(text: str) -> Tuple[str, bool]:
+ """
+ 1. Converts '' to 'mailto:foo@foo.com'
+ 2. Converts '' to 'mailto:foo@foo.com'
+ """
+ has_link = False
+ for match in re.finditer(SLACK_MAILTO_REGEX, text, re.VERBOSE):
+ has_link = True
+ text = text.replace(match.group(0), match.group(1))
+ return text, has_link