adjust_inline_image_size.rb 428 B

123456789101112131415
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class HtmlSanitizer
  3. class AdjustInlineImageSize
  4. def sanitize(string)
  5. return string if string.exclude? '<img'
  6. scrubber = HtmlSanitizer::Scrubber::Outgoing::ImageSize.new
  7. return Loofah.scrub_document(string, scrubber).to_html if string.include? '<html'
  8. Loofah.fragment(string).scrub!(scrubber).to_html
  9. end
  10. end
  11. end