rich text truelinks: Excape - in regex correctly

This commit is contained in:
Raphael Michel
2021-01-14 13:22:40 +01:00
parent 99f3360c44
commit 5375f6aec1
2 changed files with 5 additions and 1 deletions

View File

@@ -100,7 +100,7 @@ def truelink_callback(attrs, new=False):
<a href="https://maps.google.com/location/foo">https://maps.google.com</a>
"""
text = re.sub('[^a-zA-Z0-9.-/_]', '', attrs.get('_text')) # clean up link text
text = re.sub(r'[^a-zA-Z0-9.\-/_]', '', attrs.get('_text')) # clean up link text
href_url = urllib.parse.urlparse(attrs[None, 'href'])
if URL_RE.match(text) and href_url.scheme not in ('tel', 'mailto'):
# link text looks like a url