Skip to content
This repository was archived by the owner on Apr 14, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions config/initializers/fix_text_mails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module ActionView
class Template
module Handlers
class ERB
def call(template)
if template.source.encoding_aware?
# First, convert to BINARY, so in case the encoding is
# wrong, we can still find an encoding tag
# (<%# encoding %>) inside the String using a regular
# expression
template_source = template.source.dup.force_encoding("BINARY")

erb = template_source.gsub(ENCODING_TAG, '')
encoding = $2

erb.force_encoding valid_encoding(template.source.dup, encoding)

# Always make sure we return a String in the default_internal
erb.encode!
else
erb = template.source.dup
end

self.class.erb_implementation.new(
erb,
:trim => (self.class.erb_trim_mode == "-"),
:escape => template.identifier =~ /\.text/ # only escape HTML templates
).src
end
end
end
end
end