Handle truncatewords word length out of range as if no truncation is needed

This commit is contained in:
Dylan Thacker-Smith
2022-10-11 12:44:32 -04:00
parent eff2a63204
commit 4f17abfb4a
2 changed files with 6 additions and 8 deletions
+2 -4
View File
@@ -227,10 +227,8 @@ class StandardFiltersTest < Minitest::Test
assert_equal('one two three...', @filters.truncatewords("one two\tthree\nfour", 3))
assert_equal('one two...', @filters.truncatewords("one two three four", 2))
assert_equal('one...', @filters.truncatewords("one two three four", 0))
exception = assert_raises(Liquid::ArgumentError) do
@filters.truncatewords("one two three four", 1 << 31)
end
assert_equal("Liquid error: integer #{1 << 31} too big for truncatewords", exception.message)
assert_equal('one two three four', @filters.truncatewords("one two three four", 1 << 31))
assert_equal('one...', @filters.truncatewords("one two three four", -(1 << 32)))
end
def test_strip_html