Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
markdown: Expand prepare_linkifier_pattern to make it more legible.
Alex Vandiver549dd8a4c4a4
diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.pyindex 0b0896261ff..009abcf5b85 100644--- a/zerver/lib/markdown/__init__.py+++ b/zerver/lib/markdown/__init__.py@@ -1812,7 +1812,24 @@ def prepare_linkifier_pattern(source: str) -> str:whitespace, or opening delimiters, won't match if there are wordcharacters directly after, and saves what was matched asOUTER_CAPTURE_GROUP."""- return rf"""(?P<{BEFORE_CAPTURE_GROUP}>^|\s|['"\(,:<])(?P<{OUTER_CAPTURE_GROUP}>{source})(?P<{AFTER_CAPTURE_GROUP}>$|[^\pL\pN])"""+ regex = rf"""+ (?P<{BEFORE_CAPTURE_GROUP}>+ ^ |+ \s |+ ['"\(,:<]+ )+ (?P<{OUTER_CAPTURE_GROUP}>+ {source}+ )+ (?P<{AFTER_CAPTURE_GROUP}>+ $ |+ [^\pL\pN]+ )+ """+ # Strip out the spaces and newlines added to make the above+ # legible -- re2 does not have the equivalent of the /x modifier+ # that does this automatically.+ return regex.replace(" ", "").replace("\n", "")# Given a regular expression pattern, linkifies groups that match it