Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source
Show
Ignore:
Timestamp:
04/08/08 03:45:26 (6 months ago)
Author:
rick
Message:

Add config.active_support.escape_html_entities_in_json to allow disabling of html entity escaping. [rick]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/lib/active_support/json/encoders/string.rb

    r9138 r9238  
    22  module JSON 
    33    module Encoding 
     4      mattr_accessor :escape_regex 
     5 
    46      ESCAPED_CHARS = { 
    57        "\010" =>  '\b', 
     
    1820end 
    1921 
     22ActiveSupport.escape_html_entities_in_json = true 
     23 
    2024class String 
    2125  def to_json(options = nil) #:nodoc: 
    22     json = '"' + gsub(/[\010\f\n\r\t"\\><&]/) { |s| 
     26    json = '"' + gsub(ActiveSupport::JSON::Encoding.escape_regex) { |s| 
    2327      ActiveSupport::JSON::Encoding::ESCAPED_CHARS[s] 
    2428    }