module ActiveSupport::JSON::Encoding
def escape(string)
def escape(string) string = string.encode(::Encoding::UTF_8, :undef => :replace).force_encoding(::Encoding::BINARY) json = string.gsub(escape_regex) { |s| ESCAPED_CHARS[s] } json = %("#{json}") json.force_encoding(::Encoding::UTF_8) json end
def escape_html_entities_in_json=(value)
def escape_html_entities_in_json=(value) self.escape_regex = \ if @escape_html_entities_in_json = value /[\x00-\x1F"\\><&]/ else /[\x00-\x1F"\\]/ end end