From 2923d440d0ea018ab563edbdafbcc1174d7ff1b2 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 7 Jul 2019 03:19:51 -0400 Subject: [PATCH] Fix html filter autolink regex Two links in the text like "http://foo.org ... http://bar.org" were seen as a single match. --- 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 ba126855..2e9f3d7d 100644 --- a/src/python/html_filter.py +++ b/src/python/html_filter.py @@ -12,8 +12,8 @@ from html_sanitizer.sanitizer import Sanitizer class HtmlFilter: link_regexes = [re.compile(r, re.IGNORECASE) for r in [ - (r"(?P.+://(?P[a-z0-9._-]+)(?:/[/\-_.,a-z0-9%&?;=~]*)?" - r"(?:\([/\-_.,a-z0-9%&?;=~]*\))?)"), + (r"(?P[a-zA-Z\d]+://(?P[a-z\d._-]+)" + r"(?:/[/\-_.,a-z\d%&?;=~]*)?(?:\([/\-_.,a-z\d%&?;=~]*\))?)"), r"mailto:(?P[a-z0-9._-]+@(?P[a-z0-9_.-]+[a-z]))", r"tel:(?P[0-9+-]+)(?P)", r"(?Pmagnet:\?xt=urn:[a-z0-9]+:.+)(?P)",