base.rb 519 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class HtmlSanitizer
  3. module Scrubber
  4. class Base < Loofah::Scrubber
  5. HTML_DECODABLE = {
  6. '&amp;' => '&',
  7. '&lt;' => '<',
  8. '&gt;' => '>',
  9. '&quot;' => '"',
  10. '&nbsp;' => ' '
  11. }.freeze
  12. HTML_DECODABLE_REGEXP = Regexp.union(HTML_DECODABLE.keys).freeze
  13. protected
  14. def html_decode(string)
  15. string.gsub HTML_DECODABLE_REGEXP, HTML_DECODABLE
  16. end
  17. end
  18. end
  19. end