Skip to content

Instantly share code, notes, and snippets.

@mrichie
Created May 30, 2012 04:39
Show Gist options
  • Save mrichie/2833798 to your computer and use it in GitHub Desktop.
Save mrichie/2833798 to your computer and use it in GitHub Desktop.
protection
#save it as config/initializers/html_in_json.rb
ActiveSupport.escape_html_entities_in_json = true
#next line is not really compulsory. It just sanitizes output(not just replaces with \u values of html entities) to protect you from DOM XSSes.
ActiveSupport::JSON::Encoding::ESCAPED_CHARS.merge! '<' => '&lt;'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment