@@ -155,7 +155,7 @@ def test_should_allow_contenteditable
155
155
end
156
156
end
157
157
158
- HTML5 :: SafeList :: ALLOWED_URI_DATA_MEDIATYPES . each do |data_uri_type |
158
+ [ "image/gif" , "image/jpeg" , "image/png" , "text/css" , "text/plain" ] . each do |data_uri_type |
159
159
define_method "test_should_allow_data_#{ data_uri_type } _uris" do
160
160
input = %(<a href="data:#{ data_uri_type } ">foo</a>)
161
161
output = "<a href='data:#{ data_uri_type } '>foo</a>"
@@ -165,9 +165,7 @@ def test_should_allow_contenteditable
165
165
output = "<a href='data:#{ data_uri_type } ;base64,R0lGODlhAQABA'>foo</a>"
166
166
check_sanitization ( input , output , output , output )
167
167
end
168
- end
169
168
170
- HTML5 ::SafeList ::ALLOWED_URI_DATA_MEDIATYPES . each do |data_uri_type |
171
169
define_method "test_should_allow_uppercase_data_#{ data_uri_type } _uris" do
172
170
input = %(<a href="DATA:#{ data_uri_type . upcase } ">foo</a>)
173
171
output = "<a href='DATA:#{ data_uri_type . upcase } '>foo</a>"
@@ -187,6 +185,16 @@ def test_should_disallow_other_uri_mediatypes
187
185
input = %(<a href="data:image/xxx;base64,R0lGODlhAQABA">foo</a>)
188
186
output = "<a>foo</a>"
189
187
check_sanitization ( input , output , output , output )
188
+
189
+ input = %(<a href="data:text/html;base64,R0lGODlhAQABA">foo</a>)
190
+ output = "<a>foo</a>"
191
+ check_sanitization ( input , output , output , output )
192
+
193
+ # https://hackerone.com/bugs?report_id=1694173
194
+ # https://github.com/w3c/svgwg/issues/266
195
+ input = %(<svg><use href="data:image/svg+xml;base64,PHN2ZyBpZD0neCcgeG1s"/></svg>)
196
+ output = "<svg><use></use></svg>"
197
+ check_sanitization ( input , output , output , output )
190
198
end
191
199
192
200
HTML5 ::SafeList ::SVG_ALLOW_LOCAL_HREF . each do |tag_name |
0 commit comments