Skip to content

Commit

Permalink
ActionView::Helpers::TextHelper#simple_format should not change the t…
Browse files Browse the repository at this point in the history
…ext in place. Now it duplicates it.
  • Loading branch information
Casebook Developer committed Aug 4, 2011
1 parent 3a4dc9d commit f0034c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/text_helper.rb
Expand Up @@ -256,7 +256,7 @@ def word_wrap(text, *args)
# # => "<p><span>I'm allowed!</span> It's true.</p>" # # => "<p><span>I'm allowed!</span> It's true.</p>"
def simple_format(text, html_options={}, options={}) def simple_format(text, html_options={}, options={})
text = '' if text.nil? text = '' if text.nil?
text = text.dup if text.frozen? text = text.dup
start_tag = tag('p', html_options, true) start_tag = tag('p', html_options, true)
text = sanitize(text) unless options[:sanitize] == false text = sanitize(text) unless options[:sanitize] == false
text = text.to_str text = text.to_str
Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/template/text_helper_test.rb
Expand Up @@ -48,10 +48,10 @@ 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) 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 end


def test_simple_format_should_not_change_the_frozen_text_passed def test_simple_format_should_not_change_the_text_passed
text = "<b>Ok</b><script>code!</script>" text = "<b>Ok</b><script>code!</script>"
text_clone = text.dup text_clone = text.dup
simple_format(text.freeze) simple_format(text)
assert_equal text_clone, text assert_equal text_clone, text
end end


Expand Down

0 comments on commit f0034c7

Please sign in to comment.