diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-06-08 15:16:47 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-06-08 15:16:47 -0700 |
commit | 30a3b6b4fc56390eec762c879644c95cd09622b0 (patch) | |
tree | 167fbfd40a2d2d89c91fb1c9047ad264a670b336 /activesupport/lib | |
parent | d3078b540ed154b6ea245de40e8de8bba642cd02 (diff) | |
download | rails-30a3b6b4fc56390eec762c879644c95cd09622b0.tar.gz rails-30a3b6b4fc56390eec762c879644c95cd09622b0.tar.bz2 rails-30a3b6b4fc56390eec762c879644c95cd09622b0.zip |
Ruby 1.9: fix json encoding
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/json/encoding.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb index 97e573f7a6..907094a747 100644 --- a/activesupport/lib/active_support/json/encoding.rb +++ b/activesupport/lib/active_support/json/encoding.rb @@ -1,3 +1,4 @@ +# encoding: binary require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/object/instance_variables' @@ -88,8 +89,8 @@ module ActiveSupport end def escape(string) + string = string.dup.force_encoding(::Encoding::BINARY) if string.respond_to?(:force_encoding) json = '"' + string.gsub(escape_regex) { |s| ESCAPED_CHARS[s] } - json.force_encoding('ascii-8bit') if respond_to?(:force_encoding) json.gsub(/([\xC0-\xDF][\x80-\xBF]| [\xE0-\xEF][\x80-\xBF]{2}| [\xF0-\xF7][\x80-\xBF]{3})+/nx) { |s| |