Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

slack_regex: Simplify Slack regex main capture group.

PieterCKcfeb4ba73185
diff --git a/zerver/data_import/slack_message_conversion.py b/zerver/data_import/slack_message_conversion.py
index e710f696874..cb9d7033e97 100644
--- a/zerver/data_import/slack_message_conversion.py
+++ b/zerver/data_import/slack_message_conversion.py
@@ -60,7 +60,7 @@ SLACK_STRIKETHROUGH_REGEX = r"""
[\p{P}\p{Zs}\p{S}]|^
)
(\~) # followed by a ~
- ([ -}]+) # any character except ~
+ ([^~]+) # any character except ~
(\~) # followed by a ~
(
# Capture punctuation, white space, symbols or end of
@@ -80,7 +80,7 @@ SLACK_ITALIC_REGEX = r"""
[\p{P}\p{Zs}\p{S}]|^
)
(\_)
- ([ -^`-~]+) # any character except _
+ ([^_]+) # any character except _
(\_)
(
(?![_`@\\\p{Pi}\p{Ps}])
@@ -95,7 +95,7 @@ SLACK_BOLD_REGEX = r"""
[\p{P}\p{Zs}\p{S}]|^
)
(\*)
- ([ -)+-~]+) # any character except *
+ ([^*]+) # any character except *
(\*)
(
(?![*`@\\\p{Pi}\p{Ps}])
diff --git a/zerver/tests/fixtures/slack_message_conversion.json b/zerver/tests/fixtures/slack_message_conversion.json
index 8aa8c13f0df..ea3fcd6ba80 100644
--- a/zerver/tests/fixtures/slack_message_conversion.json
+++ b/zerver/tests/fixtures/slack_message_conversion.json
@@ -99,6 +99,11 @@
"name": "zero_width_identical_bold_matches_test",
"input": "*foo*\n*foo*\n*foo*",
"conversion_output": "**foo**\n**foo**\n**foo**"
+ },
+ {
+ "name": "format_emoji_test",
+ "input": "*1️⃣ bold* some _1️⃣ italic_ word ~1️⃣ strike~",
+ "conversion_output": "**1️⃣ bold** some *1️⃣ italic* word ~~1️⃣ strike~~"
}
]
}