Skip to content
This repository
Browse code

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 authored June 08, 2011
8  actionpack/lib/action_view/helpers/text_helper.rb
@@ -255,14 +255,16 @@ def word_wrap(text, *args)
255 255
       #   simple_format("<span>I'm allowed!</span> It's true.", {}, :sanitize => false)
256 256
       #   # => "<p><span>I'm allowed!</span> It's true.</p>"
257 257
       def simple_format(text, html_options={}, options={})
258  
-        text = ''.html_safe if text.nil?
  258
+        text = text ? text.to_str : ''
  259
+        text = text.dup if text.frozen?
259 260
         start_tag = tag('p', html_options, true)
260  
-        text = sanitize(text) unless options[:sanitize] == false
261 261
         text.gsub!(/\r\n?/, "\n")                    # \r\n and \r -> \n
262 262
         text.gsub!(/\n\n+/, "</p>\n\n#{start_tag}")  # 2+ newline  -> paragraph
263 263
         text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline   -> br
264 264
         text.insert 0, start_tag
265  
-        text.html_safe.safe_concat("</p>")
  265
+        text.concat("</p>")
  266
+        text = sanitize(text) unless options[:sanitize] == false
  267
+        text
266 268
       end
267 269
 
268 270
       # Creates a Cycle object whose _to_s_ method cycles through elements of an

0 notes on commit 509aa66

Please sign in to comment.
Something went wrong with that request. Please try again.