Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix `simple_format` helper to work correctly with the new SafeBuffer …

…rule.

This has been ported from `3-0-stable` [ed37964]
  • Loading branch information...
commit 509aa663601defc7c821c253d010605951e9d986 1 parent eb85169
Prem Sichanugrist sikachu authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 actionpack/lib/action_view/helpers/text_helper.rb
8 actionpack/lib/action_view/helpers/text_helper.rb
View
@@ -255,14 +255,16 @@ def word_wrap(text, *args)
# simple_format("<span>I'm allowed!</span> It's true.", {}, :sanitize => false)
# # => "<p><span>I'm allowed!</span> It's true.</p>"
def simple_format(text, html_options={}, options={})
- text = ''.html_safe if text.nil?
+ text = text ? text.to_str : ''
+ text = text.dup if text.frozen?
start_tag = tag('p', html_options, true)
- text = sanitize(text) unless options[:sanitize] == false
text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
text.gsub!(/\n\n+/, "</p>\n\n#{start_tag}") # 2+ newline -> paragraph
text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
text.insert 0, start_tag
- text.html_safe.safe_concat("</p>")
+ text.concat("</p>")
+ text = sanitize(text) unless options[:sanitize] == false
+ text
end
# Creates a Cycle object whose _to_s_ method cycles through elements of an
Please sign in to comment.
Something went wrong with that request. Please try again.