Skip to content

Commit

Permalink
use railtie to set default sanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
tongueroo committed Oct 15, 2023
1 parent 19fd6cd commit 1f673c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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" if defined?(Rails)
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

0 comments on commit 1f673c9

Please sign in to comment.