Skip to content

Commit 8173404

Browse files
mikiczhroncok
authored andcommitted
Added a test for allowed HTML attributes
1 parent 7d15673 commit 8173404

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test_naucse/test_validation.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ def test_allowed_elements():
1616
)
1717

1818

19+
def test_allow_attributes():
20+
allowed_elements = naucse.validation.AllowedElementsParser()
21+
22+
allowed_elements.reset_and_feed(
23+
"<div class='test'><span style='color: red'><a href='/courses/'>Text</a></span></div>"
24+
)
25+
26+
with pytest.raises(naucse.validation.DisallowedElement):
27+
allowed_elements.reset_and_feed(
28+
"""<div class='test' onhover="alert('XSS')"><a href='/courses/'>Text</a></div>"""
29+
)
30+
31+
1932
def test_allowed_styles():
2033
allowed_elements = naucse.validation.AllowedElementsParser()
2134

0 commit comments

Comments
 (0)