diff --git a/isso/tests/test_html.py b/isso/tests/test_html.py
index 316fbf8..327357c 100644
--- a/isso/tests/test_html.py
+++ b/isso/tests/test_html.py
@@ -65,7 +65,7 @@ class TestHTML(unittest.TestCase):
examples = [
('Look: ', 'Look: '),
('Ha',
- 'Ha'),
+ 'Ha'),
('Ha', 'Ha'),
('
Test
'), ('', 'alert("Onoe")')] @@ -93,4 +93,4 @@ class TestHTML(unittest.TestCase): }) renderer = html.Markup(conf.section("markup")).render self.assertEqual(renderer("http://example.org/ and sms:+1234567890"), - 'http://example.org/ and sms:+1234567890
') + 'http://example.org/ and sms:+1234567890
') diff --git a/isso/utils/html.py b/isso/utils/html.py index fca3c7e..1f5f8cd 100644 --- a/isso/utils/html.py +++ b/isso/utils/html.py @@ -50,6 +50,11 @@ def sanitize(tokenizer, document): if HTML5LIB_VERSION > HTML5LIB_SIMPLETREE: builder = "etree" + + for link in domtree.findall(".//{http://www.w3.org/1999/xhtml}a"): + if link.get('href', None): + link.set("rel", "nofollow noopener") + else: builder = "simpletree"