@@ -155,7 +155,7 @@ def test_should_allow_contenteditable
155155 end
156156 end
157157
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 |
159159 define_method "test_should_allow_data_#{ data_uri_type } _uris" do
160160 input = %(<a href="data:#{ data_uri_type } ">foo</a>)
161161 output = "<a href='data:#{ data_uri_type } '>foo</a>"
@@ -165,9 +165,7 @@ def test_should_allow_contenteditable
165165 output = "<a href='data:#{ data_uri_type } ;base64,R0lGODlhAQABA'>foo</a>"
166166 check_sanitization ( input , output , output , output )
167167 end
168- end
169168
170- HTML5 ::SafeList ::ALLOWED_URI_DATA_MEDIATYPES . each do |data_uri_type |
171169 define_method "test_should_allow_uppercase_data_#{ data_uri_type } _uris" do
172170 input = %(<a href="DATA:#{ data_uri_type . upcase } ">foo</a>)
173171 output = "<a href='DATA:#{ data_uri_type . upcase } '>foo</a>"
@@ -187,6 +185,16 @@ def test_should_disallow_other_uri_mediatypes
187185 input = %(<a href="data:image/xxx;base64,R0lGODlhAQABA">foo</a>)
188186 output = "<a>foo</a>"
189187 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 )
190198 end
191199
192200 HTML5 ::SafeList ::SVG_ALLOW_LOCAL_HREF . each do |tag_name |
0 commit comments