mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
rich text truelinks: Excape - in regex correctly
This commit is contained in:
@@ -100,7 +100,7 @@ def truelink_callback(attrs, new=False):
|
|||||||
|
|
||||||
<a href="https://maps.google.com/location/foo">https://maps.google.com</a>
|
<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'])
|
href_url = urllib.parse.urlparse(attrs[None, 'href'])
|
||||||
if URL_RE.match(text) and href_url.scheme not in ('tel', 'mailto'):
|
if URL_RE.match(text) and href_url.scheme not in ('tel', 'mailto'):
|
||||||
# link text looks like a url
|
# link text looks like a url
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ from pretix.base.templatetags.rich_text import (
|
|||||||
("mail@example.org",
|
("mail@example.org",
|
||||||
'<a href="mailto:mail@example.org">mail@example.org</a>'),
|
'<a href="mailto:mail@example.org">mail@example.org</a>'),
|
||||||
# Test truelink_callback
|
# Test truelink_callback
|
||||||
|
('evilsite.com',
|
||||||
|
'<a href="http://evilsite.com" rel="noopener" target="_blank">evilsite.com</a>'),
|
||||||
|
('cool-example.eu',
|
||||||
|
'<a href="http://cool-example.eu" rel="noopener" target="_blank">cool-example.eu</a>'),
|
||||||
('<a href="https://evilsite.com">Evil Site</a>',
|
('<a href="https://evilsite.com">Evil Site</a>',
|
||||||
'<a href="https://evilsite.com" rel="noopener" target="_blank">Evil Site</a>'),
|
'<a href="https://evilsite.com" rel="noopener" target="_blank">Evil Site</a>'),
|
||||||
('<a href="https://evilsite.com">evilsite.com</a>',
|
('<a href="https://evilsite.com">evilsite.com</a>',
|
||||||
|
|||||||
Reference in New Issue
Block a user