Use a better HTML sanitizer that makes sure the HTML is well formed and

can add rel="nofollow" to links.
This commit is contained in:
Tom Hughes 2010-03-06 15:38:13 +00:00
parent 30ae9fb928
commit 94f19ce3b3
3 changed files with 8 additions and 0 deletions

View file

@ -1,6 +1,10 @@
module ApplicationHelper
require 'rexml/document'
def sanitize(text)
Sanitize.clean(text, Sanitize::Config::OSM)
end
def htmlize(text)
return linkify(sanitize(simple_format(text)))
end

View file

@ -53,6 +53,7 @@ Rails::Initializer.run do |config|
config.gem 'oauth', :version => '>= 0.3.6'
config.gem 'httpclient'
config.gem 'SystemTimer', :version => '>= 1.1.3', :lib => 'system_timer'
config.gem 'sanitize'
# Only load the plugins named here, in the order given. By default, all plugins
# in vendor/plugins are loaded in alphabetical order.

View file

@ -0,0 +1,3 @@
Sanitize::Config::OSM = Sanitize::Config::RELAXED.dup
Sanitize::Config::OSM[:add_attributes] = { 'a' => { 'rel' => 'nofollow' } }