diff --git a/Gemfile b/Gemfile index ab10c23..a0970c3 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/lib/rails-html-sanitizer.rb b/lib/rails-html-sanitizer.rb index 0c48f7f..853df6f 100644 --- a/lib/rails-html-sanitizer.rb +++ b/lib/rails-html-sanitizer.rb @@ -59,3 +59,5 @@ def deprecate_option(name) end end end + +require_relative "railtie" diff --git a/lib/railtie.rb b/lib/railtie.rb new file mode 100644 index 0000000..58eae09 --- /dev/null +++ b/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