Permalink
Browse files

Make sure that we don't perform in-place mutation on SafeBuffer string

This will make sure `render :inline` is working.

Closes #1633
  • Loading branch information...
sikachu committed Jun 10, 2011
1 parent ff48edd commit 317e7c829d4b281b4e7a96fe65960c9a2b7ba664
Showing with 8 additions and 0 deletions.
  1. +3 −0 actionpack/lib/action_view/template.rb
  2. +5 −0 actionpack/test/template/template_test.rb
@@ -219,6 +219,9 @@ def compile(view, mod) #:nodoc:
method_name = self.method_name
if source.encoding_aware?
+ # Avoid performing in-place mutation for SafeBuffer
+ @source = source.to_str if source.html_safe?
+
# Look for # encoding: *. If we find one, we'll encode the
# String in that encoding, otherwise, we'll use the
# default external encoding.
@@ -173,5 +173,10 @@ def with_external_encoding(encoding)
ensure
silence_warnings { Encoding.default_external = old }
end
+
+ def test_render_inline_safebuffer_should_not_raise_error
+ @template = new_template("Hello".html_safe)
+ render
+ end
end
end

0 comments on commit 317e7c8

Please sign in to comment.