Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ jobs:
uses: fedora-python/tox-github-action@main
with:
tox_env: ${{ matrix.tox_env }}
dnf_install: gcc libxml2-devel libxslt-devel
strategy:
matrix:
tox_env:
- py36
- py38
- py39
- py310
Expand Down
6 changes: 3 additions & 3 deletions tests/test_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,20 +331,20 @@ def test_host_whitelist_slash_type_confusion(self):

def test_host_whitelist_valid(self):
# Frame with valid hostname in src is allowed.
html = '<div><iframe src="https://example.com/page"></div>'
html = '<div><iframe src="https://example.com/page"></iframe></div>'
expected = '<div><iframe src="https://example.com/page"></iframe></div>'
cleaner = Cleaner(frames=False, host_whitelist=["example.com"])
self.assertEqual(expected, cleaner.clean_html(html))

def test_host_whitelist_invalid(self):
html = '<div><iframe src="https://evil.com/page"></div>'
html = '<div><iframe src="https://evil.com/page"></iframe></div>'
expected = '<div></div>'
cleaner = Cleaner(frames=False, host_whitelist=["example.com"])
self.assertEqual(expected, cleaner.clean_html(html))

def test_host_whitelist_sneaky_userinfo(self):
# Regression test: Don't be fooled by hostname and colon in userinfo.
html = '<div><iframe src="https://example.com:@evil.com/page"></div>'
html = '<div><iframe src="https://example.com:@evil.com/page"></iframe></div>'
expected = '<div></div>'
cleaner = Cleaner(frames=False, host_whitelist=["example.com"])
self.assertEqual(expected, cleaner.clean_html(html))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_clean.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<body onload="evil_function()">
<!-- I am interpreted for EVIL! -->
<a href="javascript:evil_function()">a link</a>
<a href="javascrip%20t%20:evil_function()">a control char link</a>
<a href="j%01a%02v%03a%04s%05c%06r%07i%0Ep%20t%20:evil_function()">a control char link</a>
<a href="data:text/html;base64,PHNjcmlwdD5hbGVydCgidGVzdCIpOzwvc2NyaXB0Pg==">data</a>
<a href="#" onclick="evil_function()">another link</a>
<p onclick="evil_function()">a paragraph</p>
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py36,py38,py39,py310,py311,py312,py313,mypy
envlist = py38,py39,py310,py311,py312,py313,mypy
skipsdist = True

[testenv]
Expand Down