Sha256: e5a9607e7b225635371c20cf43143ece40d4f5dad0163ac451c19f2272a896d1
Contents?: true
Size: 934 Bytes
Versions: 42
Compression:
Stored size: 934 Bytes
Contents
module ActiveSupport module JSON module Encoding mattr_accessor :escape_regex ESCAPED_CHARS = { "\010" => '\b', "\f" => '\f', "\n" => '\n', "\r" => '\r', "\t" => '\t', '"' => '\"', '\\' => '\\\\', '>' => '\u003E', '<' => '\u003C', '&' => '\u0026' } end end end ActiveSupport.escape_html_entities_in_json = true class String def to_json(options = nil) #:nodoc: json = '"' + gsub(ActiveSupport::JSON::Encoding.escape_regex) { |s| ActiveSupport::JSON::Encoding::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| s.unpack("U*").pack("n*").unpack("H*")[0].gsub(/.{4}/, '\\\\u\&') } + '"' end end
Version data entries
42 entries across 41 versions & 14 rubygems
Version | Path |
---|---|
radiant-0.7.1 | vendor/rails/activesupport/lib/active_support/json/encoders/string.rb |
radiant-0.8.0 | vendor/rails/activesupport/lib/active_support/json/encoders/string.rb |