From fea2178461d3bc9622cf312bb013af770a4935dc Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 21 Aug 2019 14:22:34 -0400 Subject: [PATCH] Make linkify regex work with port in URL --- src/python/html_filter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python/html_filter.py b/src/python/html_filter.py index 4269ec3d..3738ff9d 100644 --- a/src/python/html_filter.py +++ b/src/python/html_filter.py @@ -13,9 +13,9 @@ class MarkdownRenderer(mistune.Renderer): class HtmlFilter: link_regexes = [re.compile(r, re.IGNORECASE) for r in [ - (r"(?P[a-zA-Z\d]+://(?P[a-z\d._-]+)" + (r"(?P[a-zA-Z\d]+://(?P[a-z\d._-]+(?:\:\d+)?)" r"(?:/[/\-_.,a-z\d%&?;=~]*)?(?:\([/\-_.,a-z\d%&?;=~]*\))?)"), - r"mailto:(?P[a-z0-9._-]+@(?P[a-z0-9_.-]+[a-z]))", + r"mailto:(?P[a-z0-9._-]+@(?P[a-z0-9_.-]+[a-z](?:\:\d+)?))", r"tel:(?P[0-9+-]+)(?P)", r"(?Pmagnet:\?xt=urn:[a-z0-9]+:.+)(?P)", ]]