mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Make sure that we don't perform in-place mutation on SafeBuffer string
This will make sure `render :inline` is working. Closes #1633
This commit is contained in:
@@ -218,6 +218,9 @@ module ActionView
|
||||
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.
|
||||
|
||||
@@ -172,5 +172,10 @@ class TestERBTemplate < ActiveSupport::TestCase
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user