From b9f5ec4b72b2eafb729f903a10d8ea915c77ca12 Mon Sep 17 00:00:00 2001 From: miruka Date: Sat, 27 Jun 2020 06:20:09 -0400 Subject: [PATCH] Fix parsing user/room ID and alias with dashes Properly highlight IDs and aliases where the server part contains a dash, e.g. "@test:example-abc.org". --- src/backend/html_markdown.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend/html_markdown.py b/src/backend/html_markdown.py index 76f40cfe..e8bd817a 100644 --- a/src/backend/html_markdown.py +++ b/src/backend/html_markdown.py @@ -120,13 +120,13 @@ class HTMLProcessor: user_id_localpart = r"[\x21-\x39\x3D-\x7E]+?" user_id_regex = re.compile( - rf"(?P@{user_id_localpart}:(?P[a-zA-Z\d.-:]*[a-zA-Z\d]))", + rf"(?P@{user_id_localpart}:(?P[a-zA-Z\d.:-]*[a-zA-Z\d]))", ) room_id_regex = re.compile( - rf"(?P!{opaque_id}:(?P[a-zA-Z\d.-:]*[a-zA-Z\d]))", + rf"(?P!{opaque_id}:(?P[a-zA-Z\d.:-]*[a-zA-Z\d]))", ) room_alias_regex = re.compile( - r"(?=^|\W)(?P#\S+?:(?P[a-zA-Z\d.-:]*[a-zA-Z\d]))", + r"(?=^|\W)(?P#\S+?:(?P[a-zA-Z\d.:-]*[a-zA-Z\d]))", ) link_regexes = [re.compile(r, re.IGNORECASE) @@ -136,7 +136,7 @@ class HTMLProcessor: r"(?:/[/\-_.,a-z\d#%&?;=~]*)?(?:\([/\-_.,a-z\d#%&?;=~]*\))?)"), # mailto: and tel: - r"mailto:(?P[a-z0-9._-]+@(?P[a-z0-9.-:]*[a-z\d]))", + r"mailto:(?P[a-z0-9._-]+@(?P[a-z0-9.:-]*[a-z\d]))", r"tel:(?P[0-9+-]+)(?P)", # magnet: