Skip to content
Browse files

Merge pull request #1787 from cmeiklejohn/make_fragment_for_more_robu…

…st_for_subclasses_of_safe_buffer

fragment_for assumes ActionView::OutputBuffer.
  • Loading branch information...
2 parents 81f7bf5 + a52e418 commit ac78ff76ad0dfcfd897d92b2d50ef0a811e8d4eb @josevalim josevalim committed
Showing with 4 additions and 6 deletions.
  1. +4 −6 actionpack/lib/action_view/helpers/cache_helper.rb
View
10 actionpack/lib/action_view/helpers/cache_helper.rb
@@ -51,12 +51,10 @@ def fragment_for(name = {}, options = nil, &block) #:nodoc:
# This dance is needed because Builder can't use capture
pos = output_buffer.length
yield
- if output_buffer.is_a?(ActionView::OutputBuffer)
- safe_output_buffer = output_buffer.to_str
- fragment = safe_output_buffer.slice!(pos..-1)
- self.output_buffer = ActionView::OutputBuffer.new(safe_output_buffer)
- else
- fragment = output_buffer.slice!(pos..-1)
+ output_safe = output_buffer.html_safe?
+ fragment = output_buffer.slice!(pos..-1)
+ if output_safe
+ self.output_buffer = output_buffer.html_safe
end
controller.write_fragment(name, fragment, options)
end

0 comments on commit ac78ff7

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