has_image_sanitized_note_examples.rb 677 B

123456789101112131415161718
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.shared_examples 'HasImageSanitizedNote' do |model_factory:|
  3. describe 'Image prevention' do
  4. context 'with inline image' do
  5. subject { create(model_factory, note: 'test 123 <img src="asd.jpg"><img src="data:image/jpeg;base64,/9j/4AAQ..."><b>some text</b>') }
  6. before do
  7. # XSS processing may run into a timeout on slow CI systems, so turn the timeout off for the test.
  8. stub_const("#{HtmlSanitizer}::PROCESSING_TIMEOUT", nil)
  9. end
  10. it 'strips out <img> tags' do
  11. expect(subject.note).to eq('test 123 <b>some text</b>')
  12. end
  13. end
  14. end
  15. end