提交 59deaecc 编写于 作者: A Akira Matsuda

Use already defined Encoding constants rather than creating one-trip Strings

上级 789df3be
......@@ -17,7 +17,7 @@ def initialize(string, encoding)
end
def message
@string.force_encoding("BINARY")
@string.force_encoding(Encoding::ASCII_8BIT)
"Your template was not saved as valid #{@encoding}. Please " \
"either specify #{@encoding} as the encoding for your template " \
"in your text editor, or mark the template with its " \
......
......@@ -81,7 +81,7 @@ def call(template)
# wrong, we can still find an encoding tag
# (<%# encoding %>) inside the String using a regular
# expression
template_source = template.source.dup.force_encoding("BINARY")
template_source = template.source.dup.force_encoding(Encoding::ASCII_8BIT)
erb = template_source.gsub(ENCODING_TAG, '')
encoding = $2
......
......@@ -158,7 +158,7 @@ def delete_entry(key, options) # :nodoc:
# characters properly.
def escape_key(key)
key = key.to_s.dup
key = key.force_encoding("BINARY")
key = key.force_encoding(Encoding::ASCII_8BIT)
key = key.gsub(ESCAPE_KEY_CHARS){ |match| "%#{match.getbyte(0).to_s(16).upcase}" }
key = "#{key[0, 213]}:md5:#{Digest::MD5.hexdigest(key)}" if key.size > 250
key
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册