1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

ActionView::Helpers::TextHelper#simple_format should not change the text in place. Now it duplicates it.

This commit is contained in:
Casebook Developer 2011-08-04 13:34:47 -04:00 committed by Xavier Noria
parent 6b80917314
commit ebfca248f9
2 changed files with 3 additions and 3 deletions

View file

@ -256,7 +256,7 @@ module ActionView
# # => "<p><span>I'm allowed!</span> It's true.</p>"
def simple_format(text, html_options={}, options={})
text = '' if text.nil?
text = text.dup if text.frozen?
text = text.dup
start_tag = tag('p', html_options, true)
text = sanitize(text) unless options[:sanitize] == false
text = text.to_str

View file

@ -48,10 +48,10 @@ class TextHelperTest < ActionView::TestCase
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
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_clone = text.dup
simple_format(text.freeze)
simple_format(text)
assert_equal text_clone, text
end