@@ -137,6 +137,16 @@ def test_strip_cdata
137
137
assert_includes ( acceptable_results , result )
138
138
end
139
139
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
+
140
150
def test_strip_blank_string
141
151
assert_nil full_sanitize ( nil )
142
152
assert_equal "" , full_sanitize ( "" )
@@ -211,6 +221,10 @@ def test_strip_links_with_unclosed_tags
211
221
assert_equal "" , link_sanitize ( "<a<a" )
212
222
end
213
223
224
+ def test_strip_links_with_passed_duck_typed_range
225
+ assert_equal "2001..2005" , link_sanitize ( 2001 ..2005 )
226
+ end
227
+
214
228
def test_strip_links_with_plaintext
215
229
assert_equal "Don't touch me" , link_sanitize ( "Don't touch me" )
216
230
end
@@ -295,6 +309,10 @@ def test_sanitize_form
295
309
assert_sanitized "<form action=\" /foo/bar\" method=\" post\" ><input></form>" , ""
296
310
end
297
311
312
+ def test_sanitize_passed_duck_typed_range
313
+ assert_sanitized 2001 ..2005 , "2001..2005"
314
+ end
315
+
298
316
def test_sanitize_plaintext
299
317
# note that the `plaintext` tag has been deprecated since HTML 2
300
318
# https://developer.mozilla.org/en-US/docs/Web/HTML/Element/plaintext
@@ -306,7 +324,19 @@ def test_sanitize_plaintext
306
324
# xerces+nekohtml-unit
307
325
"<span>foo</span></plaintext>" ,
308
326
# 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" ,
310
340
]
311
341
312
342
assert_includes ( acceptable_results , result )
0 commit comments