@@ -73,6 +73,7 @@ def test_01_sanitize(self):
73
73
("<a> </a>" , "<a> </a>" ),
74
74
# ...but breaks without any additional content are still removed
75
75
("<a><br /> </a>" , "<a> </a>" ),
76
+ ("<p>blab<br hello='world' />blub<p>" , "<p>blab<br>blub</p>" ),
76
77
]
77
78
78
79
self .run_tests (entries )
@@ -104,7 +105,9 @@ def test_03_merge(self):
104
105
self .run_tests (entries )
105
106
106
107
def test_no_space_between_same_tags (self ):
107
- entries = [("<strong>Hel</strong><strong>lo</strong>" , "<strong>Hello</strong>" )]
108
+ entries = [
109
+ ("<strong>Hel</strong><strong>lo</strong>" , "<strong>Hello</strong>" )
110
+ ]
108
111
self .run_tests (entries )
109
112
110
113
def test_04_p_in_li (self ):
@@ -642,3 +645,13 @@ def test_code_whitespace(self):
642
645
"""
643
646
644
647
self .run_tests ([(html , html )], sanitizer = sanitizer )
648
+
649
+ def test_br_attribute_sanitization (self ):
650
+ """Attributes which aren't allowlisted are removed from br tags"""
651
+ self .run_tests (
652
+ [
653
+ ("<p><br hello=\" alert('world');\" /><br></p>" , "" ),
654
+ ('<p hello="world"></p>' , "" ),
655
+ ("<br hello=\" alert('world');\" /><br>" , "<br>" ),
656
+ ]
657
+ )
0 commit comments