Christoph Schiessl
2011-Jun-08 12:10 UTC
"Cannot modify SafeBuffer in place" thrown by CacheHelper
After upgrading from 3.0.7 to 3.0.8, I get the following error: activesupport (3.0.8) lib/active_support/core_ext/string/ output_safety.rb:114:in `slice!'' actionpack (3.0.8) lib/action_view/helpers/cache_helper.rb:56:in `fragment_for'' actionpack (3.0.8) lib/action_view/helpers/cache_helper.rb:38:in `cache'' app/views/customers/index.html.erb:18:in `_app_views_customers_index_html_erb__218860319__625647498_0'' ... As far as I can tell, the method `fragment_for` in `CacheHelper` is calling `slice!` on a `SafeBuffer` object. def fragment_for(name = {}, options = nil, &block) #:nodoc: if controller.fragment_exist?(name, options) controller.read_fragment(name, options) else # VIEW TODO: Make #capture usable outside of ERB # This dance is needed because Builder can''t use capture pos = output_buffer.length yield fragment = output_buffer.slice!(pos..-1) # PROBLEM controller.write_fragment(name, fragment, options) end end However, `slice!` is also one of the unsafe methods defined in `ActiveSupport::SafeBuffer`. Therefore an exception is thrown. Best regards, Christoph Schiessl -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Konstantin Shababov
2011-Jun-08 17:21 UTC
Re: "Cannot modify SafeBuffer in place" thrown by CacheHelper
you can fix this using output_buffer = output_buffer.slice(pos..-1) instead of using slice! -- Konstantin Shababov http://github.com/etehtseaSent with Sparrow (http://www.sparrowmailapp.com/?sig) On Wednesday, June 8, 2011 at 7:10 PM, Christoph Schiessl wrote:> After upgrading from 3.0.7 to 3.0.8, I get the following error: > > activesupport (3.0.8) lib/active_support/core_ext/string/ > output_safety.rb:114:in `slice!'' > actionpack (3.0.8) lib/action_view/helpers/cache_helper.rb:56:in > `fragment_for'' > actionpack (3.0.8) lib/action_view/helpers/cache_helper.rb:38:in > `cache'' > app/views/customers/index.html.erb:18:in > `_app_views_customers_index_html_erb__218860319__625647498_0'' > ... > > As far as I can tell, the method `fragment_for` in `CacheHelper` is > calling `slice!` on a `SafeBuffer` object. > > def fragment_for(name = {}, options = nil, &block) #:nodoc: > if controller.fragment_exist?(name, options) > controller.read_fragment(name, options) > else > # VIEW TODO: Make #capture usable outside of ERB > # This dance is needed because Builder can''t use capture > pos = output_buffer.length > yield > fragment = output_buffer.slice!(pos..-1) # > PROBLEM > controller.write_fragment(name, fragment, options) > end > end > > However, `slice!` is also one of the unsafe methods defined in > `ActiveSupport::SafeBuffer`. Therefore an exception is thrown. > > Best regards, > Christoph Schiessl > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com (mailto:rubyonrails-core@googlegroups.com). > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com (mailto:rubyonrails-core+unsubscribe@googlegroups.com). > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Prem Sichanugrist
2011-Jun-08 17:25 UTC
Re: "Cannot modify SafeBuffer in place" thrown by CacheHelper
This has been resolved in the `3-0-stable` branch. I''d suggest you to downgrade your application and wait for release, or point your Gemfile to 3-0-stable. gem ''rails'', :git => "git://github.com/rails/rails.git", :branch => "3-0-stable" Thanks, Prem On Jun 8, 2011, at 8:10 AM, Christoph Schiessl wrote:> After upgrading from 3.0.7 to 3.0.8, I get the following error: > > activesupport (3.0.8) lib/active_support/core_ext/string/ > output_safety.rb:114:in `slice!'' > actionpack (3.0.8) lib/action_view/helpers/cache_helper.rb:56:in > `fragment_for'' > actionpack (3.0.8) lib/action_view/helpers/cache_helper.rb:38:in > `cache'' > app/views/customers/index.html.erb:18:in > `_app_views_customers_index_html_erb__218860319__625647498_0'' > ... > > As far as I can tell, the method `fragment_for` in `CacheHelper` is > calling `slice!` on a `SafeBuffer` object. > > def fragment_for(name = {}, options = nil, &block) #:nodoc: > if controller.fragment_exist?(name, options) > controller.read_fragment(name, options) > else > # VIEW TODO: Make #capture usable outside of ERB > # This dance is needed because Builder can''t use capture > pos = output_buffer.length > yield > fragment = output_buffer.slice!(pos..-1) # > PROBLEM > controller.write_fragment(name, fragment, options) > end > end > > However, `slice!` is also one of the unsafe methods defined in > `ActiveSupport::SafeBuffer`. Therefore an exception is thrown. > > Best regards, > Christoph Schiessl > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Ryan Bigg
2011-Jun-09 09:11 UTC
Re: "Cannot modify SafeBuffer in place" thrown by CacheHelper
This should also be fixed in the next release of Rails 3.0.x On 09/06/2011, at 3:21, Konstantin Shababov <mail@etehtsea.me> wrote:> you can fix this using output_buffer = output_buffer.slice(pos..-1) instead of using slice! > > -- > Konstantin Shababov > http://github.com/etehtsea > Sent with Sparrow > On Wednesday, June 8, 2011 at 7:10 PM, Christoph Schiessl wrote: > >> After upgrading from 3.0.7 to 3.0.8, I get the following error: >> >> activesupport (3.0.8) lib/active_support/core_ext/string/ >> output_safety.rb:114:in `slice!'' >> actionpack (3.0.8) lib/action_view/helpers/cache_helper.rb:56:in >> `fragment_for'' >> actionpack (3.0.8) lib/action_view/helpers/cache_helper.rb:38:in >> `cache'' >> app/views/customers/index.html.erb:18:in >> `_app_views_customers_index_html_erb__218860319__625647498_0'' >> ... >> >> As far as I can tell, the method `fragment_for` in `CacheHelper` is >> calling `slice!` on a `SafeBuffer` object. >> >> def fragment_for(name = {}, options = nil, &block) #:nodoc: >> if controller.fragment_exist?(name, options) >> controller.read_fragment(name, options) >> else >> # VIEW TODO: Make #capture usable outside of ERB >> # This dance is needed because Builder can''t use capture >> pos = output_buffer.length >> yield >> fragment = output_buffer.slice!(pos..-1) ## >> PROBLEM >> controller.write_fragment(name, fragment, options) >> end >> end >> >> However, `slice!` is also one of the unsafe methods defined in >> `ActiveSupport::SafeBuffer`. Therefore an exception is thrown. >> >> Best regards, >> Christoph Schiessl >> >> -- >> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. >> To post to this group, send email to rubyonrails-core@googlegroups.com. >> To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. >> For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Simon de Boer
2011-Jun-13 15:21 UTC
Re: "Cannot modify SafeBuffer in place" thrown by CacheHelper
This problem seems to be more widespread: xx = "safe string".html_safe xx.underscore xx.titlecase xx.pluralize Each inflection throws the same exception. Inflections should be safe operations...shouldn''t they? (although xx.(upcase|downcase|dasherize) are fine) On Jun 9, 5:11 am, Ryan Bigg <radarliste...@gmail.com> wrote:> This should also be fixed in the next release of Rails 3.0.x > > On 09/06/2011, at 3:21, Konstantin Shababov <m...@etehtsea.me> wrote: > > > > > you can fix this using output_buffer = output_buffer.slice(pos..-1) instead of using slice! > > > -- > > Konstantin Shababov > >http://github.com/etehtsea > > Sent with Sparrow > > On Wednesday, June 8, 2011 at 7:10 PM, Christoph Schiessl wrote: > > >> After upgrading from 3.0.7 to 3.0.8, I get the following error: > > >> activesupport (3.0.8) lib/active_support/core_ext/string/ > >> output_safety.rb:114:in `slice!'' > >> actionpack (3.0.8) lib/action_view/helpers/cache_helper.rb:56:in > >> `fragment_for'' > >> actionpack (3.0.8) lib/action_view/helpers/cache_helper.rb:38:in > >> `cache'' > >> app/views/customers/index.html.erb:18:in > >> `_app_views_customers_index_html_erb__218860319__625647498_0'' > >> ... > > >> As far as I can tell, the method `fragment_for` in `CacheHelper` is > >> calling `slice!` on a `SafeBuffer` object. > > >> def fragment_for(name = {}, options = nil, &block) #:nodoc: > >> if controller.fragment_exist?(name, options) > >> controller.read_fragment(name, options) > >> else > >> # VIEW TODO: Make #capture usable outside of ERB > >> # This dance is needed because Builder can''t use capture > >> pos = output_buffer.length > >> yield > >> fragment = output_buffer.slice!(pos..-1) ## > >> PROBLEM > >> controller.write_fragment(name, fragment, options) > >> end > >> end > > >> However, `slice!` is also one of the unsafe methods defined in > >> `ActiveSupport::SafeBuffer`. Therefore an exception is thrown. > > >> Best regards, > >> Christoph Schiessl > > >> -- > >> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > >> To post to this group, send email to rubyonrails-core@googlegroups.com. > >> To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > >> For more options, visit this group athttp://groups.google.com/group/rubyonrails-core?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > > To post to this group, send email to rubyonrails-core@googlegroups.com. > > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Prem Sichanugrist
2011-Jun-13 15:30 UTC
Re: Re: "Cannot modify SafeBuffer in place" thrown by CacheHelper
I haven''t verified it yet, but it doesn''t really look like in-place methods. Do you mind open up a ticket in Github? Thank you, Prem On Jun 13, 2011, at 11:21 AM, Simon de Boer wrote:> This problem seems to be more widespread: > xx = "safe string".html_safe > xx.underscore > xx.titlecase > xx.pluralize > > Each inflection throws the same exception. Inflections should be safe > operations...shouldn''t they? > > (although xx.(upcase|downcase|dasherize) are fine) > > On Jun 9, 5:11 am, Ryan Bigg <radarliste...@gmail.com> wrote: >> This should also be fixed in the next release of Rails 3.0.x >> >> On 09/06/2011, at 3:21, Konstantin Shababov <m...@etehtsea.me> wrote: >> >> >> >>> you can fix this using output_buffer = output_buffer.slice(pos..-1) instead of using slice! >> >>> -- >>> Konstantin Shababov >>> http://github.com/etehtsea >>> Sent with Sparrow >>> On Wednesday, June 8, 2011 at 7:10 PM, Christoph Schiessl wrote: >> >>>> After upgrading from 3.0.7 to 3.0.8, I get the following error: >> >>>> activesupport (3.0.8) lib/active_support/core_ext/string/ >>>> output_safety.rb:114:in `slice!'' >>>> actionpack (3.0.8) lib/action_view/helpers/cache_helper.rb:56:in >>>> `fragment_for'' >>>> actionpack (3.0.8) lib/action_view/helpers/cache_helper.rb:38:in >>>> `cache'' >>>> app/views/customers/index.html.erb:18:in >>>> `_app_views_customers_index_html_erb__218860319__625647498_0'' >>>> ... >> >>>> As far as I can tell, the method `fragment_for` in `CacheHelper` is >>>> calling `slice!` on a `SafeBuffer` object. >> >>>> def fragment_for(name = {}, options = nil, &block) #:nodoc: >>>> if controller.fragment_exist?(name, options) >>>> controller.read_fragment(name, options) >>>> else >>>> # VIEW TODO: Make #capture usable outside of ERB >>>> # This dance is needed because Builder can''t use capture >>>> pos = output_buffer.length >>>> yield >>>> fragment = output_buffer.slice!(pos..-1) ## >>>> PROBLEM >>>> controller.write_fragment(name, fragment, options) >>>> end >>>> end >> >>>> However, `slice!` is also one of the unsafe methods defined in >>>> `ActiveSupport::SafeBuffer`. Therefore an exception is thrown. >> >>>> Best regards, >>>> Christoph Schiessl >> >>>> -- >>>> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. >>>> To post to this group, send email to rubyonrails-core@googlegroups.com. >>>> To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. >>>> For more options, visit this group athttp://groups.google.com/group/rubyonrails-core?hl=en. >> >>> -- >>> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. >>> To post to this group, send email to rubyonrails-core@googlegroups.com. >>> To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. >>> For more options, visit this group athttp://groups.google.com/group/rubyonrails-core?hl=en. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.