Skip to content
This repository
Browse code

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...
commit 115e80dccc65c3ed9a9750649d9ca4ea2a7e64f1 1 parent 3757798
Prem Sichanugrist sikachu authored
3  actionpack/lib/action_view/template.rb
@@ -218,6 +218,9 @@ def compile(view, mod) #:nodoc:
218 218 method_name = self.method_name
219 219
220 220 if source.encoding_aware?
  221 + # Avoid performing in-place mutation for SafeBuffer
  222 + @source = source.to_str if source.html_safe?
  223 +
221 224 # Look for # encoding: *. If we find one, we'll encode the
222 225 # String in that encoding, otherwise, we'll use the
223 226 # default external encoding.
5 actionpack/test/template/template_test.rb
@@ -172,5 +172,10 @@ def with_external_encoding(encoding)
172 172 ensure
173 173 silence_warnings { Encoding.default_external = old }
174 174 end
  175 +
  176 + def test_render_inline_safebuffer_should_not_raise_error
  177 + @template = new_template("Hello".html_safe)
  178 + render
  179 + end
175 180 end
176 181 end

0 comments on commit 115e80d

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