diff options
-rw-r--r-- | actionpack/lib/action_view/template/handlers/erb.rb | 4 | ||||
-rw-r--r-- | actionpack/test/template/template_test.rb | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/template/handlers/erb.rb b/actionpack/lib/action_view/template/handlers/erb.rb index bbf012ab15..cbed0108cf 100644 --- a/actionpack/lib/action_view/template/handlers/erb.rb +++ b/actionpack/lib/action_view/template/handlers/erb.rb @@ -7,7 +7,7 @@ module ActionView class OutputBuffer < ActiveSupport::SafeBuffer def initialize(*) super - encode! + encode! if encoding_aware? end def <<(value) @@ -106,6 +106,8 @@ module ActionView if !encoding && (template.source.encoding == Encoding::BINARY) raise WrongEncodingError.new(template_source, Encoding.default_external) end + else + erb = template.source.dup end result = self.class.erb_implementation.new( diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb index c4a65d84fc..995d728d50 100644 --- a/actionpack/test/template/template_test.rb +++ b/actionpack/test/template/template_test.rb @@ -1,9 +1,11 @@ require "abstract_unit" -# These are the normal settings that will be set up by Railties -# TODO: Have these tests support other combinations of these values -Encoding.default_internal = "UTF-8" -Encoding.default_external = "UTF-8" +if "ruby".encoding_aware? + # These are the normal settings that will be set up by Railties + # TODO: Have these tests support other combinations of these values + Encoding.default_internal = "UTF-8" + Encoding.default_external = "UTF-8" +end class TestERBTemplate < ActiveSupport::TestCase ERBHandler = ActionView::Template::Handlers::ERB |