Skip to content

Commit 35549ef

Browse files
authored
Merge pull request #414 from gjtorikian/fix-sanitization-only
Bugfix: sanitization-only filters should still work
2 parents ba6ec7f + 109cc11 commit 35549ef

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

lib/html_pipeline.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ def call(text, context: {}, result: {})
183183

184184
if @node_filters.empty?
185185
instrument("sanitization.html_pipeline", payload) do
186-
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters, options: rewriter_options).rewrite(html)
187-
end unless @convert_filter.nil? # no html, so no sanitization
186+
result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, options: rewriter_options).rewrite(html)
187+
end
188188
else
189189
instrument("call_node_filters.html_pipeline", payload) do
190190
@node_filters.each { |filter| filter.context = (filter.context || {}).merge(context) }

lib/html_pipeline/version.rb

Lines changed: 1 addition & 1 deletion
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.1"
4+
VERSION = "3.2.2"
55
end

test/sanitization_filter_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,5 +289,23 @@ def test_sanitization_pipeline_does_not_need_node_filters
289289

290290
assert_equal(result[:output].to_s, expected.chomp)
291291
end
292+
293+
def test_a_sanitization_only_pipeline_works
294+
config = Selma::Sanitizer::Config.freeze_config({
295+
elements: [
296+
"strong",
297+
],
298+
})
299+
300+
pipeline = HTMLPipeline.new(
301+
sanitization_config: config,
302+
)
303+
304+
text = "<p>Some <strong>plain</strong> text</p>"
305+
result = pipeline.call(text)
306+
expected = "Some <strong>plain</strong> text"
307+
308+
assert_equal(result[:output].to_s, expected)
309+
end
292310
end
293311
end

0 commit comments

Comments
 (0)