From a98b89e9bcb56b9adc3a4b0bef3e9844bf93bfd0 Mon Sep 17 00:00:00 2001 From: Jan Provaznik Date: Fri, 16 Aug 2019 10:22:57 +0200 Subject: Re-escape whole HTML content instead of only match When we un-escape HTML text to find references in it, we should then re-escape the whole text again, not only found matches. Because we replace matches with milestone/label links (which contain HTML tags we don't want to escape again), we re-escape HTML text with placeholders instead of these links and then replace placeholders in the escaped text. --- spec/lib/banzai/filter/label_reference_filter_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'spec/lib/banzai/filter/label_reference_filter_spec.rb') diff --git a/spec/lib/banzai/filter/label_reference_filter_spec.rb b/spec/lib/banzai/filter/label_reference_filter_spec.rb index 213a5459118..35e99d2586e 100644 --- a/spec/lib/banzai/filter/label_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/label_reference_filter_spec.rb @@ -10,6 +10,11 @@ describe Banzai::Filter::LabelReferenceFilter do let(:label) { create(:label, project: project) } let(:reference) { label.to_reference } + it_behaves_like 'HTML text with references' do + let(:resource) { label } + let(:resource_text) { resource.title } + end + it 'requires project context' do expect { described_class.call('') }.to raise_error(ArgumentError, /:project/) end -- cgit v1.2.3