@@ -137,6 +137,16 @@ def test_strip_cdata
137137 assert_includes ( acceptable_results , result )
138138 end
139139
140+ def test_strip_passed_passed_duck_typed_range
141+ input = 2000 ..2005
142+ result = full_sanitize ( input )
143+ acceptable_results = [
144+ "2000..2005" ,
145+ ]
146+
147+ assert_includes ( acceptable_results , result )
148+ end
149+
140150 def test_strip_blank_string
141151 assert_nil full_sanitize ( nil )
142152 assert_equal "" , full_sanitize ( "" )
@@ -211,6 +221,10 @@ def test_strip_links_with_unclosed_tags
211221 assert_equal "" , link_sanitize ( "<a<a" )
212222 end
213223
224+ def test_strip_links_with_passed_duck_typed_range
225+ assert_equal "2001..2005" , link_sanitize ( 2001 ..2005 )
226+ end
227+
214228 def test_strip_links_with_plaintext
215229 assert_equal "Don't touch me" , link_sanitize ( "Don't touch me" )
216230 end
@@ -295,6 +309,10 @@ def test_sanitize_form
295309 assert_sanitized "<form action=\" /foo/bar\" method=\" post\" ><input></form>" , ""
296310 end
297311
312+ def test_sanitize_passed_duck_typed_range
313+ assert_sanitized 2001 ..2005 , "2001..2005"
314+ end
315+
298316 def test_sanitize_plaintext
299317 # note that the `plaintext` tag has been deprecated since HTML 2
300318 # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/plaintext
@@ -306,7 +324,19 @@ def test_sanitize_plaintext
306324 # xerces+nekohtml-unit
307325 "<span>foo</span></plaintext>" ,
308326 # xerces+cyberneko
309- "<span>foo</span>"
327+ "<span>foo</span>" ,
328+ ]
329+
330+ assert_includes ( acceptable_results , result )
331+ end
332+
333+ def test_safe_sanitize_passed_duck_typed_range
334+ # note that the `plaintext` tag has been deprecated since HTML 2
335+ # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/plaintext
336+ input = 2001 ..2005
337+ result = safe_list_sanitize ( input )
338+ acceptable_results = [
339+ "2001..2005" ,
310340 ]
311341
312342 assert_includes ( acceptable_results , result )
0 commit comments