Skip to content

Commit

Permalink
Move tested contents to files
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun authored and HamptonMakes committed Jul 15, 2020
1 parent 6a71578 commit a0f27aa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
4 changes: 4 additions & 0 deletions test/results/escape_safe_buffer.xhtml
@@ -0,0 +1,4 @@
<div data-html='&lt;foo&gt;bar&lt;/foo&gt;'></div>
<meta content='&#39;&quot;' />
<meta content='&#39;&quot;' />
<meta content='&#39;&quot;' />
15 changes: 3 additions & 12 deletions test/template_test.rb
Expand Up @@ -248,18 +248,9 @@ def test_xss_protection_in_attributes
end

def test_xss_protection_in_attributes_with_safe_strings
assert_equal("<div data-html='&lt;foo&gt;bar&lt;/foo&gt;'></div>\n", render('%div{ "data-html" => "<foo>bar</foo>".html_safe }', :action_view))
assert_equal(<<-HTML, render(<<-HAML, :action_view))
<meta content='&#39;&quot;' />
<meta content='&#39;&quot;' />
<meta content='&#39;&quot;' />
HTML
%meta{ content: %{'"}.html_safe }
- val = %{'"}.html_safe
%meta{ content: val }
- hash = { content: val }
%meta{ hash }
HAML
assert_renders_correctly('escape_safe_buffer') do |name|
render(File.read(File.expand_path("templates/#{name}.haml", __dir__)), :action_view)
end
end

def test_xss_protection_with_bang_in_interpolation
Expand Down
6 changes: 6 additions & 0 deletions test/templates/escape_safe_buffer.haml
@@ -0,0 +1,6 @@
%div{ 'data-html' => '<foo>bar</foo>'.html_safe }
%meta{ content: %{'"}.html_safe }
- val = %{'"}.html_safe
%meta{ content: val }
- hash = { content: val }
%meta{ hash }

0 comments on commit a0f27aa

Please sign in to comment.