Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_has_nofollow_already(self):
attrs = {
(None, 'href'): 'http://example.com',
(None, 'rel'): 'nofollow',
}
assert nofollow(attrs) == attrs
def test_mailto(self):
attrs = {(None, 'href'): 'mailto:joe@example.com'}
assert nofollow(attrs) == attrs
def test_other_rel(self):
attrs = {
(None, 'href'): 'http://example.com',
(None, 'rel'): 'next',
}
assert (
nofollow(attrs) ==
{(None, 'href'): 'http://example.com', (None, 'rel'): 'next nofollow'}
)
def html(self, node):
"""The cleaned HTML of the page"""
sanitized_content = render_content(self.content, node=node)
try:
return linkify(
sanitized_content,
[nofollow, ],
)
except TypeError:
logger.warning('Returning unlinkified content.')
return sanitized_content