Skip to content

Commit e37debb

Browse files
committed
add failing test
1 parent 8264b72 commit e37debb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/sanitizer_test.rb

+10
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,16 @@ def test_allow_data_attribute_if_requested
515515
assert_equal %(<a data-foo="foo">foo</a>), safe_list_sanitize(text, attributes: ['data-foo'])
516516
end
517517

518+
def test_sanitize_data_protocol
519+
text = "- XSS\"><iframe src=\"data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4\">- XSS\"><iframe src=\"data:application/vnd.wap.xhtml+xml;base64,PHg6c2NyaXB0IHhtbG5zOng9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGh0bWwiPmFsZXJ0KGRvY3VtZW50LmRvbWFpbik8L3g6c2NyaXB0Pg==\">"
520+
521+
scope_allowed_tags %w(iframe) do
522+
scope_allowed_attributes %w(src) do
523+
assert_equal %(- XSS\"&gt;<iframe>- XSS\"&gt;<iframe></iframe></iframe>), safe_list_sanitize(text)
524+
end
525+
end
526+
end
527+
518528
def test_uri_escaping_of_href_attr_in_a_tag_in_safe_list_sanitizer
519529
skip if RUBY_VERSION < "2.3"
520530

0 commit comments

Comments
 (0)