aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json/encoding.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-05-10 14:40:35 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-05-10 14:40:35 -0300
commite4ec944eacbb58ed682614cb3271dc58e4d71b52 (patch)
tree44cf76e435636bc907934133c07ee89056eafb92 /activesupport/lib/active_support/json/encoding.rb
parent1f11dbf0b4dacede0da1be1a0675e501d1b0fced (diff)
parent9d6a5b44320bb4655cf7b633668fed1ab8ddcac2 (diff)
downloadrails-e4ec944eacbb58ed682614cb3271dc58e4d71b52.tar.gz
rails-e4ec944eacbb58ed682614cb3271dc58e4d71b52.tar.bz2
rails-e4ec944eacbb58ed682614cb3271dc58e4d71b52.zip
Merge branch 'fix-json-encoding'
This is the compination of #10057 and 10534. Closes #10320
Diffstat (limited to 'activesupport/lib/active_support/json/encoding.rb')
-rw-r--r--activesupport/lib/active_support/json/encoding.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb
index 9bf1ea35b3..7f8b41d218 100644
--- a/activesupport/lib/active_support/json/encoding.rb
+++ b/activesupport/lib/active_support/json/encoding.rb
@@ -1,3 +1,5 @@
+#encoding: us-ascii
+
require 'active_support/core_ext/object/to_json'
require 'active_support/core_ext/module/delegation'
require 'active_support/json/variable'
@@ -98,13 +100,18 @@ module ActiveSupport
"\010" => '\b',
"\f" => '\f',
"\n" => '\n',
+ "\xe2\x80\xa8" => '\u2028',
+ "\xe2\x80\xa9" => '\u2029',
"\r" => '\r',
"\t" => '\t',
'"' => '\"',
'\\' => '\\\\',
'>' => '\u003E',
'<' => '\u003C',
- '&' => '\u0026' }
+ '&' => '\u0026',
+ "#{0xe2.chr}#{0x80.chr}#{0xa8.chr}" => '\u2028',
+ "#{0xe2.chr}#{0x80.chr}#{0xa9.chr}" => '\u2029',
+ }
class << self
# If true, use ISO 8601 format for dates and times. Otherwise, fall back
@@ -121,9 +128,9 @@ module ActiveSupport
def escape_html_entities_in_json=(value)
self.escape_regex = \
if @escape_html_entities_in_json = value
- /[\x00-\x1F"\\><&]/
+ /\xe2\x80\xa8|\xe2\x80\xa9|[\x00-\x1F"\\><&]/
else
- /[\x00-\x1F"\\]/
+ /\xe2\x80\xa8|\xe2\x80\xa9|[\x00-\x1F"\\]/
end
end