mirror of
https://github.com/Shopify/liquid.git
synced 2025-08-31 00:03:18 -04:00
Ensure raw tag has no arguments
This commit is contained in:
parent
86d8b552da
commit
719a98a25e
@ -1,6 +1,7 @@
|
||||
---
|
||||
errors:
|
||||
syntax:
|
||||
tag_unexpected_args: "Syntax Error in '%{tag}' - Valid syntax: %{tag}"
|
||||
assign: "Syntax Error in 'assign' - Valid syntax: assign [var] = [source]"
|
||||
capture: "Syntax Error in 'capture' - Valid syntax: capture [var]"
|
||||
case: "Syntax Error in 'case' - Valid syntax: case [condition]"
|
||||
|
@ -1,7 +1,16 @@
|
||||
module Liquid
|
||||
class Raw < Block
|
||||
Syntax = /\A\s*\z/om
|
||||
FullTokenPossiblyInvalid = /\A(.*)#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}\z/om
|
||||
|
||||
def initialize(tag_name, markup, options)
|
||||
super
|
||||
|
||||
unless markup =~ Syntax
|
||||
raise SyntaxError.new(@options[:locale].t("errors.syntax.tag_unexpected_args".freeze, tag: tag_name))
|
||||
end
|
||||
end
|
||||
|
||||
def parse(tokens)
|
||||
@body = ''
|
||||
while token = tokens.shift
|
||||
|
@ -24,6 +24,7 @@ class RawTagTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_invalid_raw
|
||||
assert_match_syntax_error /tag was never closed/, '{% raw } foo {% endraw %}'
|
||||
assert_match_syntax_error /tag was never closed/, '{% raw %} foo'
|
||||
assert_match_syntax_error /Valid syntax/, '{% raw } foo %}{% endraw %}'
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user