From c3bda6c3894528fb211c582c5b8da8d6ae125e52 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Fri, 22 Sep 2017 11:51:09 -0400 Subject: Re-allow `name` attribute on user-provided anchor HTML --- spec/lib/banzai/filter/sanitization_filter_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/lib/banzai/filter/sanitization_filter_spec.rb b/spec/lib/banzai/filter/sanitization_filter_spec.rb index 01ceb21dfaa..69bd062ebcd 100644 --- a/spec/lib/banzai/filter/sanitization_filter_spec.rb +++ b/spec/lib/banzai/filter/sanitization_filter_spec.rb @@ -101,16 +101,18 @@ describe Banzai::Filter::SanitizationFilter do expect(filter(act).to_html).to eq exp end - it 'disallows the `name` attribute globally' do + it 'disallows the `name` attribute globally, allows on `a`' do html = <<~HTML Hi + Bye HTML doc = filter(html) expect(doc.at_css('img')).not_to have_attribute('name') expect(doc.at_css('span')).not_to have_attribute('name') + expect(doc.at_css('a')).to have_attribute('name') end it 'allows `summary` elements' do -- cgit v1.2.1 From f6bc4403d2f83e5571a06af3ad0989422bf23c12 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Fri, 22 Sep 2017 11:54:35 -0400 Subject: Make the "customizes the whitelist only once" spec less brittle --- spec/lib/banzai/filter/sanitization_filter_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/lib/banzai/filter/sanitization_filter_spec.rb b/spec/lib/banzai/filter/sanitization_filter_spec.rb index 69bd062ebcd..5f41e28fece 100644 --- a/spec/lib/banzai/filter/sanitization_filter_spec.rb +++ b/spec/lib/banzai/filter/sanitization_filter_spec.rb @@ -47,9 +47,11 @@ describe Banzai::Filter::SanitizationFilter do describe 'custom whitelist' do it 'customizes the whitelist only once' do instance = described_class.new('Foo') + control_count = instance.whitelist[:transformers].size + 3.times { instance.whitelist } - expect(instance.whitelist[:transformers].size).to eq 5 + expect(instance.whitelist[:transformers].size).to eq control_count end it 'sanitizes `class` attribute from all elements' do -- cgit v1.2.1