diff options
Diffstat (limited to 'activesupport/lib/active_support/json/encoding.rb')
-rw-r--r-- | activesupport/lib/active_support/json/encoding.rb | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb index 925fa2a2c7..d7181035d3 100644 --- a/activesupport/lib/active_support/json/encoding.rb +++ b/activesupport/lib/active_support/json/encoding.rb @@ -119,9 +119,7 @@ module ActiveSupport end def escape(string) - if string.respond_to?(:force_encoding) - string = string.encode(::Encoding::UTF_8, :undef => :replace).force_encoding(::Encoding::BINARY) - end + string = string.encode(::Encoding::UTF_8, :undef => :replace).force_encoding(::Encoding::BINARY) json = string. gsub(escape_regex) { |s| ESCAPED_CHARS[s] }. gsub(/([\xC0-\xDF][\x80-\xBF]| @@ -130,7 +128,7 @@ module ActiveSupport s.unpack("U*").pack("n*").unpack("H*")[0].gsub(/.{4}/n, '\\\\u\&') } json = %("#{json}") - json.force_encoding(::Encoding::UTF_8) if json.respond_to?(:force_encoding) + json.force_encoding(::Encoding::UTF_8) json end end @@ -281,4 +279,4 @@ class DateTime strftime('%Y/%m/%d %H:%M:%S %z') end end -end
\ No newline at end of file +end |