ActionView::Template::Error (Cannot modify SafeBuffer in place):

Hello,

Trying to upgrade an app that was running fine in 3.0.3 to 3.0.9 and while everything works well, I get this error:

ActionView::Template::Error (Cannot modify SafeBuffer in place):

When passing a string to this function (in application_helper.rb) through a simple: <%= format_me(article[shortdesc])%>

def format_me(text, html_options={}, options={})     text = ''.html_safe if text.nil?     start_tag = tag('p class=grey', 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><br />\n\n#{start_tag}") # 2+ newline -

paragraph

    text.gsub!(/\r\r+/, "</p><br />\n\n#{start_tag}") # 2+ newline -

paragraph

    text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br     text.gsub!("*b*", '<b>')     text.gsub!("*bb*", '</b>')     text.gsub!("*r*", '<span class=red>')     text.gsub!("*rr*", '</span>')     text.gsub!("*sp*", '&nbsp;')     text.insert 0, start_tag     text.html_safe.safe_concat("</p>")   end

I don't understand well enough what changed between 3.0.3 and 3.0.9 to understand what I should change in this function and what part is now wrong.

Can anyone help? Thanks!

Cedric Tineo

I don't understand well enough what changed between 3.0.3 and 3.0.9 to understand what I should change in this function and what part is now wrong.

In a nutshell, don't call gsub! on strings that have been marked as safe

Fred