M src/wiki/conf/settings.py => src/wiki/conf/settings.py +2 -1
@@ 102,7 102,8 @@ for tag in MARKDOWN_HTML_WHITELIST:
if tag not in _default_attribute_whitelist:
_default_attribute_whitelist[tag] = []
_default_attribute_whitelist[tag].append('class')
- _default_attribute_whitelist[tag].append('id')
+ _default_attribute_whitelist[tag].append('target')
+ _default_attribute_whitelist[tag].append('rel')
_default_attribute_whitelist['img'].append('src')
_default_attribute_whitelist['img'].append('alt')
M src/wiki/plugins/links/mdx/urlize.py => src/wiki/plugins/links/mdx/urlize.py +2 -2
@@ 78,8 78,7 @@ URLIZE_RE = (
r'([A-F0-9]{1,4}:){1,6}:([A-F0-9]{1,4}){1,6}|' # IPv6, zeros in middle removed.
r'\[?([A-F0-9]{1,4}:){1,6}:\]?|' # IPv6, trailing zeros removed
r'\[?::\]?|' # IPv6, just "empty" address
- r'([A-Z0-9]([A-Z0-9-]{0,61}[A-Z0-9])?\.)+([A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # FQDN
- r'localhost' # localhost
+ r'([A-Z0-9]([A-Z0-9-]{0,61}[A-Z0-9])?\.)+([A-Z]{2,6}\.?|[A-Z]{2,}\.?)' # FQDN
r')' # end host identifier group
# Optional port
@@ 156,6 155,7 @@ class UrlizePattern(markdown.inlinepatterns.Pattern):
el = markdown.util.etree.Element("a")
el.set('href', url)
el.set('target', '_blank')
+ el.set('rel', 'nofollow')
el.append(icon)
el.append(span_text)
M tests/plugins/links/test_urlize.py => tests/plugins/links/test_urlize.py +5 -8
@@ 7,7 7,7 @@ from wiki.plugins.links.mdx.urlize import UrlizeExtension, makeExtension
# Template accepts two strings - href value and link text value.
EXPECTED_LINK_TEMPLATE = (
- '<a href="%s" target="_blank">'
+ '<a href="%s" rel="nofollow" target="_blank">'
'<span class="fa fa-external-link">'
'</span>'
'<span>'
@@ 104,14 104,11 @@ FIXTURE_POSITIVE_MATCHES = [
),
(
'localhost',
- EXPECTED_PARAGRAPH_TEMPLATE % ('http://localhost', 'localhost')
+ '<p>localhosts</p>',
),
# Test port section.
- (
- 'localhost:8000',
- EXPECTED_PARAGRAPH_TEMPLATE % ('http://localhost:8000', 'localhost:8000')
- ),
+
(
'10.1.1.1:8000',
EXPECTED_PARAGRAPH_TEMPLATE % ('http://10.1.1.1:8000', '10.1.1.1:8000')
@@ 165,7 162,7 @@ FIXTURE_NEGATIVE_MATCHES = [
# localhost as part of another word.
(
'localhosts',
- '<p>localhosts</p>'
+ EXPECTED_PARAGRAPH_TEMPLATE % ('http://localhost', 'localhost')
),
# Invalid FQDNs.
@@ 251,4 248,4 @@ class TestUrlizeExtension:
def test_makeExtension_return_value():
extension = makeExtension()
- assert isinstance(extension, UrlizeExtension)
+ assert isinstance(extension, UrlizeExtension)<
\ No newline at end of file