mirror of
https://github.com/kemko/liquid.git
synced 2026-01-04 17:25:41 +03:00
Merge pull request #476 from Shopify/missing-variable-name-error
Disallow filters with no variable in strict mode
This commit is contained in:
@@ -62,8 +62,8 @@ module Liquid
|
||||
|
||||
@filters = []
|
||||
p = Parser.new(markup)
|
||||
# Could be just filters with no input
|
||||
@name = p.look(:pipe) ? nil : Expression.parse(p.expression)
|
||||
|
||||
@name = Expression.parse(p.expression)
|
||||
while p.consume?(:pipe)
|
||||
filtername = p.consume(:id)
|
||||
filterargs = p.consume?(:colon) ? parse_filterargs(p) : []
|
||||
|
||||
@@ -28,11 +28,14 @@ class ParsingQuirksTest < Minitest::Test
|
||||
|
||||
def test_error_on_empty_filter
|
||||
assert Template.parse("{{test}}")
|
||||
assert Template.parse("{{|test}}")
|
||||
|
||||
with_error_mode(:lax) do
|
||||
assert Template.parse("{{|test}}")
|
||||
end
|
||||
|
||||
with_error_mode(:strict) do
|
||||
assert_raises(SyntaxError) do
|
||||
Template.parse("{{test |a|b|}}")
|
||||
end
|
||||
assert_raises(SyntaxError) { Template.parse("{{|test}}") }
|
||||
assert_raises(SyntaxError) { Template.parse("{{test |a|b|}}") }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user