Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use railtie to set default sanitizer #170

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Gemfile
Expand Up @@ -18,3 +18,7 @@ end
# specify gem versions for old rubies
gem "nokogiri", RUBY_VERSION < "2.1" ? "~> 1.6.0" : ">= 1.7"
gem "activesupport", RUBY_VERSION < "2.2.2" ? "~> 4.2.0" : ">= 5"

group :test do
gem "rails", "~> 7.1.1"
end
2 changes: 2 additions & 0 deletions lib/rails-html-sanitizer.rb
Expand Up @@ -59,3 +59,5 @@ def deprecate_option(name)
end
end
end

require_relative "railtie"
18 changes: 18 additions & 0 deletions lib/railtie.rb
@@ -0,0 +1,18 @@
# frozen_string_literal: true

require "rails"
require "rails/html/sanitizer"

module Rails
module HTML
class Sanitizer
class Railtie < Rails::Railtie # :nodoc:
initializer "rails_html_sanitizer.sanitizer_vendor" do |app|
ActiveSupport.on_load(:action_view) do
ActionView::Helpers::SanitizeHelper.sanitizer_vendor = Rails::HTML4::Sanitizer
end
end
end
end
end
end