cid_to_src_spec.rb 928 B

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe HtmlSanitizer::CidToSrc do
  4. let(:scrubber) { described_class.new }
  5. describe('#scrubber') do
  6. subject(:actual) { fragment.scrub!(scrubber).to_html }
  7. let(:fragment) { Loofah.fragment(input) }
  8. describe 'does not touch images without cid' do
  9. let(:input) { '<img src="test.jpg">' }
  10. let(:target) { '<img src="test.jpg">' }
  11. it { is_expected.to match target }
  12. end
  13. describe 'replaces source to cid when present' do
  14. let(:input) { '<img src="test.jpg" cid="img_cid">' }
  15. let(:target) { '<img src="cid:img_cid">' }
  16. it { is_expected.to match target }
  17. end
  18. describe 'does not touch non-images' do
  19. let(:input) { '<div cid="test"></div>' }
  20. let(:target) { '<div cid="test"></div>' }
  21. it { is_expected.to match target }
  22. end
  23. end
  24. end