1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

use the source returned from encode!

This commit is contained in:
Aaron Patterson 2019-01-31 14:06:21 -08:00
parent eda0f574f1
commit 916b74d16a
No known key found for this signature in database
GPG key ID: 953170BCB4FFAFC6

View file

@ -202,7 +202,9 @@ module ActionView
# before passing the source on to the template engine, leaving a
# blank line in its stead.
def encode!
return unless source.encoding == Encoding::BINARY
source = self.source
return source unless source.encoding == Encoding::BINARY
# Look for # encoding: *. If we find one, we'll encode the
# String in that encoding, otherwise, we'll use the
@ -290,7 +292,7 @@ module ActionView
# In general, this means that templates will be UTF-8 inside of Rails,
# regardless of the original source encoding.
def compile(mod)
encode!
source = encode!
code = @handler.call(self)
# Make sure that the resulting String to be eval'd is in the
@ -312,7 +314,7 @@ module ActionView
# handler is valid in the default_internal. This is for handlers
# that handle encoding but screw up
unless source.valid_encoding?
raise WrongEncodingError.new(@source, Encoding.default_internal)
raise WrongEncodingError.new(source, Encoding.default_internal)
end
mod.module_eval(source, identifier, 0)