Skip to content

Commit 1d0ba0c

Browse files
committed
Merge pull request #35 from rails/pass-options-to-sanitize
Pass options to the text method.
2 parents 1206877 + a454c6a commit 1d0ba0c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/rails/html/sanitizer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def sanitize(html, options = {})
2828

2929
Loofah.fragment(html).tap do |fragment|
3030
remove_xpaths(fragment, XPATHS_TO_REMOVE)
31-
end.text
31+
end.text(options)
3232
end
3333
end
3434

test/sanitizer_test.rb

+5
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ def test_strip_tags_with_frozen_string
104104
assert_equal "Frozen string with no tags", full_sanitize("Frozen string with no tags".freeze)
105105
end
106106

107+
def test_full_sanitize_allows_turning_off_encoding_special_chars
108+
assert_equal '&', full_sanitize('&')
109+
assert_equal '&', full_sanitize('&', encode_special_chars: false)
110+
end
111+
107112
def test_strip_links_with_tags_in_tags
108113
expected = "a href='hello'&gt;all <b>day</b> long/a&gt;"
109114
input = "<<a>a href='hello'>all <b>day</b> long<</A>/a>"

0 commit comments

Comments
 (0)