Skip to content

Commit 7ef86f4

Browse files
committed
isso: html.py: Prevent auto creation of invalid links
Fixes #557
1 parent 9755fe6 commit 7ef86f4

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

isso/tests/test_html.py

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def test_sanitizer(self):
6767
['<a href="http://example.org/" rel="nofollow noopener">Ha</a>',
6868
'<a rel="nofollow noopener" href="http://example.org/">Ha</a>']),
6969
('<a href="sms:+1234567890">Ha</a>', '<a>Ha</a>'),
70+
('ld.so', 'ld.so'),
71+
('/usr/lib/x86_64-linux-gnu/libc/memcpy-preload.so', '/usr/lib/x86_64-linux-gnu/libc/memcpy-preload.so'),
7072
('<p style="visibility: hidden;">Test</p>', '<p>Test</p>'),
7173
('<script>alert("Onoe")</script>', 'alert("Onoe")')]
7274

isso/utils/html.py

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def sanitize(self, text):
2727
clean_html = bleach.clean(text, tags=self.elements, attributes=self.attributes, strip=True)
2828

2929
def set_links(attrs, new=False):
30+
# Linker can misinterpret text as a domain name and create new invalid links.
31+
# To prevent this, we only allow existing links to be modified.
32+
if new:
33+
return None
34+
3035
href_key = (None, u'href')
3136

3237
if href_key not in attrs:

0 commit comments

Comments
 (0)