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

Inherit TimelineEventPipeline from PlainMarkdownPipeline

parent bdcd884f
......@@ -2,34 +2,24 @@
module Banzai
module Pipeline
class TimelineEventPipeline < BasePipeline
class TimelineEventPipeline < PlainMarkdownPipeline
ALLOWLIST = Banzai::Filter::SanitizationFilter::LIMITED.deep_dup.merge(
elements: %w(p b i strong em pre code a img)
)
def self.filters
@filters ||= FilterArray[
Filter::MarkdownFilter,
*super,
*reference_filters,
Filter::EmojiFilter,
Filter::ExternalLinkFilter,
Filter::ImageLinkFilter,
Filter::SanitizationFilter,
*reference_filters
Filter::SanitizationFilter
]
end
def self.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
]
Banzai::Pipeline::GfmPipeline.reference_filters
end
def self.transform_context(context)
......
......@@ -8,15 +8,7 @@ RSpec.describe Banzai::Pipeline::TimelineEventPipeline do
describe '.reference_filters' do
it 'contains required reference filters' do
expect(described_class.reference_filters).to contain_exactly(
Banzai::Filter::References::UserReferenceFilter,
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
*Banzai::Pipeline::GfmPipeline.reference_filters
)
end
end
......@@ -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>') }
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>'}
it 'filters out not allowed tags' do
it 'filters out banned tags' do
is_expected.to eq(' div h1 ')
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