# Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ require 'rails_helper' RSpec.describe HtmlSanitizer::Scrubber::Wipe do let(:scrubber) { described_class.new } describe('#scrubber') do subject(:actual) do # export with extra options to avoid html indentation fragment.scrub!(scrubber) .to_html save_with: Nokogiri::XML::Node::SaveOptions::DEFAULT_HTML ^ Nokogiri::XML::Node::SaveOptions::FORMAT end let(:fragment) { Loofah.fragment(input) } context 'when has not allowed tag' do let(:input) { 'asd' } let(:target) { 'asd' } it { is_expected.to eq target } end context 'when has not allowed tag in not allowed' do let(:input) { 'asd' } let(:target) { 'asd' } it { is_expected.to eq target } end context 'when has not allowed tag inside of an allowed tag' do let(:input) { '
' } let(:target) { '
' } it { is_expected.to eq target } end context 'when insecure source' do let(:input) { '' } let(:target) { '' } it { is_expected.to eq target } end context 'when has not allowed classes' do let(:input) { '
test
' } let(:target) { '
test
' } it { is_expected.to eq target } end context 'when has width and height attributes' do let(:input) { '' } let(:target) { '' } it { is_expected.to eq target } end context 'when has width and max-width attributes' do let(:input) { '' } let(:target) { '' } it { is_expected.to eq target } end context 'when has not allowed attributes' do let(:input) { '
test
' } let(:target) { '
test
' } it { is_expected.to eq target } end context 'when has style' do let(:input) { '
test
test
' } let(:target) { '
test
test
' } it { is_expected.to eq target } end context 'when has executeable link' do let(:input) { '' } let(:target) { '' } it { is_expected.to eq target } it 'does not mark remote content as removed' do expect { actual }.not_to change(scrubber, :remote_content_removed) end end context 'when has an image with a proper link' do let(:input) { '' } let(:target) { '' } it { is_expected.to eq target } it 'does mark remote content as removed' do expect { actual }.to change(scrubber, :remote_content_removed).from(false).to(true) end end end end