diff options
Diffstat (limited to 'activesupport/lib/active_support/json/encoders')
-rw-r--r-- | activesupport/lib/active_support/json/encoders/string.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/json/encoders/string.rb b/activesupport/lib/active_support/json/encoders/string.rb index 7ddc544294..ca74436802 100644 --- a/activesupport/lib/active_support/json/encoders/string.rb +++ b/activesupport/lib/active_support/json/encoders/string.rb @@ -9,8 +9,9 @@ module ActiveSupport "\t" => '\t', '"' => '\"', '\\' => '\\\\', - ">" => '\076', - '<' => '\074', + '>' => '\u003E', + '<' => '\u003C', + '&' => '\u0026', '/' => '\\/' } end @@ -19,7 +20,7 @@ end class String def to_json(options = nil) #:nodoc: - '"' + gsub(/[\010\f\n\r\t"\\><\/]/) { |s| + '"' + gsub(/[\010\f\n\r\t"\\><&\/]/) { |s| ActiveSupport::JSON::Encoding::ESCAPED_CHARS[s] }.gsub(/([\xC0-\xDF][\x80-\xBF]| [\xE0-\xEF][\x80-\xBF]{2}| |