Skip to content

Commit bdea438

Browse files
committed
Allow for "just text" pipelines
1 parent 713f663 commit bdea438

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

lib/html_pipeline.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ def call(text, context: {}, result: {})
181181
},
182182
}
183183

184-
if @node_filters.empty?
184+
if @node_filters.empty? && !@sanitization_config.nil?
185185
instrument("sanitization.html_pipeline", payload) do
186186
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, options: rewriter_options).rewrite(html)
187187
end
188-
else
188+
elsif @node_filters.any?
189189
instrument("call_node_filters.html_pipeline", payload) do
190190
@node_filters.each { |filter| filter.context = (filter.context || {}).merge(context) }
191191
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters, options: rewriter_options).rewrite(html)

lib/html_pipeline/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
class HTMLPipeline
4-
VERSION = "3.2.2"
4+
VERSION = "3.2.3"
55
end

test/html_pipeline_test.rb

+12
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ def test_incorrect_node_filters
104104
end
105105
end
106106

107+
def test_just_text_filters
108+
text = "Hey there, @billy."
109+
110+
pipeline = HTMLPipeline.new(
111+
text_filters: [TestReverseFilter.new],
112+
convert_filter: nil,
113+
)
114+
result = pipeline.call(text)[:output]
115+
116+
assert_equal(".yllib@ ,ereht yeH", result)
117+
end
118+
107119
def test_kitchen_sink
108120
text = "Hey there, @billy. Love to see <marquee>yah</marquee>!"
109121

0 commit comments

Comments
 (0)