forked from rails/rails_xss
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for not considering escape paramter for content_tag_string and te…
…sts to check that
- Loading branch information
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'test_helper' | ||
|
||
class TagHelperTest < ActionView::TestCase | ||
|
||
def test_content_tag | ||
assert_equal "<a href=\"create\">Create</a>", content_tag("a", "Create", "href" => "create") | ||
assert content_tag("a", "Create", "href" => "create").html_safe? | ||
assert_equal content_tag("a", "Create", "href" => "create"), | ||
content_tag("a", "Create", :href => "create") | ||
assert_equal "<p><script>evil_js</script></p>", | ||
content_tag(:p, '<script>evil_js</script>') | ||
assert_equal "<p><script>evil_js</script></p>", | ||
content_tag(:p, '<script>evil_js</script>', nil, false) | ||
end | ||
|
||
def test_tag_honors_html_safe_for_param_values | ||
['1&2', '1 < 2', '“test“'].each do |escaped| | ||
assert_equal %(<a href="#{escaped}" />), tag('a', :href => escaped.html_safe) | ||
end | ||
end | ||
end |