@@ -63,25 +63,32 @@ def test_sanitizer():
63
63
for ns , tag_name in sanitizer .allowed_elements :
64
64
if ns != constants .namespaces ["html" ]:
65
65
continue
66
- if tag_name in ['caption' , 'col' , 'colgroup' , 'optgroup' , 'option' , 'table' , 'tbody' , 'td' ,
67
- 'tfoot' , 'th' , 'thead' , 'tr' , 'select' ]:
66
+ if tag_name in ['caption' , 'col' , 'colgroup' , 'optgroup' , 'option' ,
67
+ 'table' , 'tbody' , 'td' , 'tfoot' , 'th' , 'thead' ,
68
+ 'tr' , 'select' ]:
68
69
continue # TODO
69
70
if tag_name == 'image' :
70
71
yield (runSanitizerTest , "test_should_allow_%s_tag" % tag_name ,
71
- "<img title=\" 1\" />foo <bad>bar</bad> baz" ,
72
- "<%s title='1'>foo <bad>bar</bad> baz</%s>" % (tag_name , tag_name ))
72
+ "<img title=\" 1\" />foo <bad>bar</bad> baz" ,
73
+ "<%s title='1'>foo <bad>bar</bad> baz</%s>" %
74
+ (tag_name , tag_name ))
73
75
elif tag_name == 'br' :
74
76
yield (runSanitizerTest , "test_should_allow_%s_tag" % tag_name ,
75
- "<br title=\" 1\" />foo <bad>bar</bad> baz<br/>" ,
76
- "<%s title='1'>foo <bad>bar</bad> baz</%s>" % (tag_name , tag_name ))
77
+ "<br title=\" 1\" />foo <bad>bar</bad> baz<br/>" ,
78
+ "<%s title='1'>foo <bad>bar</bad> baz</%s>" %
79
+ (tag_name , tag_name ))
77
80
elif tag_name in constants .voidElements :
78
81
yield (runSanitizerTest , "test_should_allow_%s_tag" % tag_name ,
79
- "<%s title=\" 1\" />foo <bad>bar</bad> baz" % tag_name ,
80
- "<%s title='1'>foo <bad>bar</bad> baz</%s>" % (tag_name , tag_name ))
82
+ "<%s title=\" 1\" />foo <bad>bar</bad> baz" %
83
+ tag_name ,
84
+ "<%s title='1'>foo <bad>bar</bad> baz</%s>" %
85
+ (tag_name , tag_name ))
81
86
else :
82
87
yield (runSanitizerTest , "test_should_allow_%s_tag" % tag_name ,
83
- "<%s title=\" 1\" >foo <bad>bar</bad> baz</%s>" % (tag_name , tag_name ),
84
-
8000
span> "<%s title='1'>foo <bad>bar</bad> baz</%s>" % (tag_name , tag_name ))
88
+ "<%s title=\" 1\" >foo <bad>bar</bad> baz</%s>" %
89
+ (tag_name , tag_name ),
90
+ "<%s title='1'>foo <bad>bar</bad> baz</%s>" %
91
+ (tag_name , tag_name ))
85
92
86
93
for ns , attribute_name in sanitizer .allowed_attributes :
87
94
if ns is not None :
@@ -92,27 +99,30 @@ def test_sanitizer():
92
99
continue
93
100
attribute_value = 'foo'
94
101
if attribute_name in sanitizer .attr_val_is_uri :
95
- attribute_value = '%s://sub.domain.tld/path/object.ext' % sanitizer .allowed_protocols [0 ]
102
+ attribute_value = '%s://sub.domain.tld/path/object.ext' \
103
+ % sanitizer .allowed_protocols [0 ]
96
104
yield (runSanitizerTest , "test_should_allow_%s_attribute" % attribute_name ,
97
- "<p %s=\" %s\" >foo <bad>bar</bad> baz</p>" % (attribute_name , attribute_value ),
98
- "<p %s='%s'>foo <bad>bar</bad> baz</p>" % (attribute_name , attribute_value ))
105
+ "<p %s=\" %s\" >foo <bad>bar</bad> baz</p>" %
106
+ (attribute_name , attribute_value ),
107
+ "<p %s='%s'>foo <bad>bar</bad> baz</p>" %
108
+ (attribute_name , attribute_value ))
99
109
100
110
for protocol in sanitizer .allowed_protocols :
101
111
rest_of_uri = '//sub.domain.tld/path/object.ext'
102
112
if protocol == 'data' :
103
113
rest_of_uri = 'image/png;base64,aGVsbG8gd29ybGQ='
104
114
yield (runSanitizerTest , "test_should_allow_uppercase_%s_uris" % protocol ,
105
- "<img src=\" %s:%s\" >foo</a>" % (protocol , rest_of_uri ),
106
- """ <img src="%s:%s">foo</a>""" % (protocol , rest_of_uri ))
115
+ "<img src=\" %s:%s\" >foo</a>" % (protocol , rest_of_uri ),
116
+ ' <img src="%s:%s">foo</a>' % (protocol , rest_of_uri ))
107
117
108
118
for protocol in sanitizer .allowed_protocols :
109
119
rest_of_uri = '//sub.domain.tld/path/object.ext'
110
120
if protocol == 'data' :
111
121
rest_of_uri = 'image/png;base64,aGVsbG8gd29ybGQ='
112
122
protocol = protocol .upper ()
113
123
yield (runSanitizerTest , "test_should_allow_uppercase_%s_uris" % protocol ,
114
- "<img src=\" %s:%s\" >foo</a>" % (protocol , rest_of_uri ),
115
- """ <img src="%s:%s">foo</a>""" % (protocol , rest_of_uri ))
124
+ "<img src=\" %s:%s\" >foo</a>" % (protocol , rest_of_uri ),
125
+ ' <img src="%s:%s">foo</a>' % (protocol , rest_of_uri ))
116
126
117
127
118
128
def test_lowercase_color_codes_in_style ():
0 commit comments