mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 11:20:41 -07:00
Don't allow identifiers to end in a dash in strict parse mode.
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ module Liquid
|
|||||||
'?'.freeze => :question,
|
'?'.freeze => :question,
|
||||||
'-'.freeze => :dash
|
'-'.freeze => :dash
|
||||||
}
|
}
|
||||||
IDENTIFIER = /[a-zA-Z_][\w-]*\??/
|
IDENTIFIER = /[a-zA-Z_](?:[\w-]*\w)?\??/
|
||||||
SINGLE_STRING_LITERAL = /'[^\']*'/
|
SINGLE_STRING_LITERAL = /'[^\']*'/
|
||||||
DOUBLE_STRING_LITERAL = /"[^\"]*"/
|
DOUBLE_STRING_LITERAL = /"[^\"]*"/
|
||||||
NUMBER_LITERAL = /-?\d+(\.\d+)?/
|
NUMBER_LITERAL = /-?\d+(\.\d+)?/
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ class LexerUnitTest < Minitest::Test
|
|||||||
|
|
||||||
tokens = Lexer.new('2foo').tokenize
|
tokens = Lexer.new('2foo').tokenize
|
||||||
assert_equal [[:number, '2'], [:id, 'foo'], [:end_of_string]], tokens
|
assert_equal [[:number, '2'], [:id, 'foo'], [:end_of_string]], tokens
|
||||||
|
|
||||||
|
tokens = Lexer.new('foo-bar-baz-').tokenize
|
||||||
|
assert_equal [[:id, 'foo-bar-baz'], [:dash, "-"], [:end_of_string]], tokens
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_whitespace
|
def test_whitespace
|
||||||
|
|||||||
Reference in New Issue
Block a user