aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json/encoders/string.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/json/encoders/string.rb')
-rw-r--r--activesupport/lib/active_support/json/encoders/string.rb19
1 files changed, 10 insertions, 9 deletions
diff --git a/activesupport/lib/active_support/json/encoders/string.rb b/activesupport/lib/active_support/json/encoders/string.rb
index 963cd10969..7ddc544294 100644
--- a/activesupport/lib/active_support/json/encoders/string.rb
+++ b/activesupport/lib/active_support/json/encoders/string.rb
@@ -3,14 +3,15 @@ module ActiveSupport
module Encoding
ESCAPED_CHARS = {
"\010" => '\b',
- "\f" => '\f',
- "\n" => '\n',
- "\r" => '\r',
- "\t" => '\t',
- '"' => '\"',
- '\\' => '\\\\',
- ">" => '\076',
- '<' => '\074'
+ "\f" => '\f',
+ "\n" => '\n',
+ "\r" => '\r',
+ "\t" => '\t',
+ '"' => '\"',
+ '\\' => '\\\\',
+ ">" => '\076',
+ '<' => '\074',
+ '/' => '\\/'
}
end
end
@@ -18,7 +19,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}|