mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 11:20:41 -07:00
Prevent Range usage in templates from blowing up
This commit is contained in:
@@ -25,6 +25,12 @@ class Numeric # :nodoc:
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Range # :nodoc:
|
||||||
|
def to_liquid
|
||||||
|
self
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class Time # :nodoc:
|
class Time # :nodoc:
|
||||||
def to_liquid
|
def to_liquid
|
||||||
self
|
self
|
||||||
|
|||||||
@@ -306,4 +306,14 @@ class TemplateTest < Minitest::Test
|
|||||||
t.render!({ 'x' => 'foo' }, { strict_filters: true })
|
t.render!({ 'x' => 'foo' }, { strict_filters: true })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_using_range_literal_works_as_expected
|
||||||
|
t = Template.parse("{% assign foo = (x..y) %}{{ foo }}")
|
||||||
|
result = t.render({ 'x' => 1, 'y' => 5 })
|
||||||
|
assert_equal '1..5', result
|
||||||
|
|
||||||
|
t = Template.parse("{% assign nums = (x..y) %}{% for num in nums %}{{ num }}{% endfor %}")
|
||||||
|
result = t.render({ 'x' => 1, 'y' => 5 })
|
||||||
|
assert_equal '12345', result
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user