Skip to content

Commit

Permalink
Merge pull request #12760 from pseidemann/master
Browse files Browse the repository at this point in the history
fix simple_format escapes own output when sanitize is set to true
Conflicts:

	actionpack/lib/action_view/helpers/text_helper.rb
	actionview/CHANGELOG.md
  • Loading branch information
senny committed Nov 9, 2013
1 parent 664716b commit 86e126d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions actionpack/CHANGELOG.md
@@ -1,3 +1,7 @@
* Fix `simple_format` escapes own output when passing `sanitize: true`

*Paul Seidemann*

* Don't let strong parameters mutate the given hash via `fetch`

Create a new instance if the given parameter is a `Hash` instead of
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/text_helper.rb
Expand Up @@ -266,7 +266,7 @@ def simple_format(text, html_options = {}, options = {})
content_tag(wrapper_tag, nil, html_options)
else
paragraphs.map { |paragraph|
content_tag(wrapper_tag, paragraph, html_options, options[:sanitize])
content_tag(wrapper_tag, paragraph, html_options, false)
}.join("\n\n").html_safe
end
end
Expand Down
5 changes: 5 additions & 0 deletions actionpack/test/template/text_helper_test.rb
Expand Up @@ -42,6 +42,11 @@ def test_simple_format_should_sanitize_input_when_sanitize_option_is_not_false
assert_equal "<p><b> test with unsafe string </b></p>", simple_format("<b> test with unsafe string </b><script>code!</script>")
end

def test_simple_format_should_sanitize_input_when_sanitize_option_is_true
assert_equal '<p><b> test with unsafe string </b></p>',
simple_format('<b> test with unsafe string </b><script>code!</script>', {}, sanitize: true)
end

def test_simple_format_should_not_sanitize_input_when_sanitize_option_is_false
assert_equal "<p><b> test with unsafe string </b><script>code!</script></p>", simple_format("<b> test with unsafe string </b><script>code!</script>", {}, :sanitize => false)
end
Expand Down

0 comments on commit 86e126d

Please sign in to comment.