Don't allow identifiers to end in a dash in strict parse mode.

This commit is contained in:
Dylan Thacker-Smith
2015-07-30 22:50:34 -04:00
parent fc1c0d0d83
commit b140e91d8e
2 changed files with 4 additions and 1 deletions

View File

@@ -13,7 +13,7 @@ module Liquid
'?'.freeze => :question,
'-'.freeze => :dash
}
IDENTIFIER = /[a-zA-Z_][\w-]*\??/
IDENTIFIER = /[a-zA-Z_](?:[\w-]*\w)?\??/
SINGLE_STRING_LITERAL = /'[^\']*'/
DOUBLE_STRING_LITERAL = /"[^\"]*"/
NUMBER_LITERAL = /-?\d+(\.\d+)?/

View File

@@ -36,6 +36,9 @@ class LexerUnitTest < Minitest::Test
tokens = Lexer.new('2foo').tokenize
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
def test_whitespace