tag_remove.rb 594 B

12345678910111213141516171819202122232425
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class HtmlSanitizer
  3. module Scrubber
  4. class TagRemove < Base
  5. # @param tags [Array<String,Symbol>] list of tags to remove. Defaults to .tags_remove_content
  6. def initialize(tags: nil)
  7. super()
  8. @tags = tags || self.class.tags_remove_content
  9. end
  10. def scrub(node)
  11. return if @tags.exclude?(node.name)
  12. node.remove
  13. STOP
  14. end
  15. def self.tags_remove_content
  16. Rails.configuration.html_sanitizer_tags_remove_content
  17. end
  18. end
  19. end
  20. end