Commit 7982f091 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Inherit TimelineEventPipeline from PlainMarkdownPipeline

parent bdcd884f
...@@ -2,34 +2,24 @@ ...@@ -2,34 +2,24 @@
module Banzai module Banzai
module Pipeline module Pipeline
class TimelineEventPipeline < BasePipeline class TimelineEventPipeline < PlainMarkdownPipeline
ALLOWLIST = Banzai::Filter::SanitizationFilter::LIMITED.deep_dup.merge( ALLOWLIST = Banzai::Filter::SanitizationFilter::LIMITED.deep_dup.merge(
elements: %w(p b i strong em pre code a img) elements: %w(p b i strong em pre code a img)
) )
def self.filters def self.filters
@filters ||= FilterArray[ @filters ||= FilterArray[
Filter::MarkdownFilter, *super,
*reference_filters,
Filter::EmojiFilter, Filter::EmojiFilter,
Filter::ExternalLinkFilter, Filter::ExternalLinkFilter,
Filter::ImageLinkFilter, Filter::ImageLinkFilter,
Filter::SanitizationFilter, Filter::SanitizationFilter
*reference_filters
] ]
end end
def self.reference_filters def self.reference_filters
[ Banzai::Pipeline::GfmPipeline.reference_filters
Filter::References::UserReferenceFilter,
Filter::References::IssueReferenceFilter,
Filter::References::ExternalIssueReferenceFilter,
Filter::References::MergeRequestReferenceFilter,
Filter::References::SnippetReferenceFilter,
Filter::References::CommitRangeReferenceFilter,
Filter::References::CommitReferenceFilter,
Filter::References::AlertReferenceFilter,
Filter::References::FeatureFlagReferenceFilter
]
end end
def self.transform_context(context) def self.transform_context(context)
......
...@@ -8,15 +8,7 @@ RSpec.describe Banzai::Pipeline::TimelineEventPipeline do ...@@ -8,15 +8,7 @@ RSpec.describe Banzai::Pipeline::TimelineEventPipeline do
describe '.reference_filters' do describe '.reference_filters' do
it 'contains required reference filters' do it 'contains required reference filters' do
expect(described_class.reference_filters).to contain_exactly( expect(described_class.reference_filters).to contain_exactly(
Banzai::Filter::References::UserReferenceFilter, *Banzai::Pipeline::GfmPipeline.reference_filters
Banzai::Filter::References::IssueReferenceFilter,
Banzai::Filter::References::ExternalIssueReferenceFilter,
Banzai::Filter::References::MergeRequestReferenceFilter,
Banzai::Filter::References::SnippetReferenceFilter,
Banzai::Filter::References::CommitRangeReferenceFilter,
Banzai::Filter::References::CommitReferenceFilter,
Banzai::Filter::References::AlertReferenceFilter,
Banzai::Filter::References::FeatureFlagReferenceFilter
) )
end end
end end
...@@ -30,10 +22,10 @@ RSpec.describe Banzai::Pipeline::TimelineEventPipeline do ...@@ -30,10 +22,10 @@ RSpec.describe Banzai::Pipeline::TimelineEventPipeline do
it { is_expected.to eq('<p><strong>bold</strong> <em>italic</em> <code>code</code></p>') } it { is_expected.to eq('<p><strong>bold</strong> <em>italic</em> <code>code</code></p>') }
end end
context 'when markdown contains not allowed HTML tags' do context 'when markdown contains banned HTML tags' do
let(:markdown) { '<div>div</div><h1>h1</h1>'} let(:markdown) { '<div>div</div><h1>h1</h1>'}
it 'filters out not allowed tags' do it 'filters out banned tags' do
is_expected.to eq(' div h1 ') is_expected.to eq(' div h1 ')
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment