3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -79,10 +79,17 @@ def parse_number(markup, ss)
79
79
end
80
80
81
81
ss . string = markup
82
- # the first byte must be a digit, a period, or a dash
82
+ # the first byte must be a digit or a dash
83
83
byte = ss . scan_byte
84
84
85
- return false if byte != DASH && byte != DOT && ( byte < ZERO || byte > NINE )
85
+ return false if byte != DASH && ( byte < ZERO || byte > NINE )
86
+
87
+ if byte == DASH
88
+ peek_byte = ss . peek_byte
89
+
90
+ # if it starts with a dash, the next byte must be a digit
91
+ return false if peek_byte . nil? || !( peek_byte >= ZERO && peek_byte <= NINE )
92
+ end
86
93
87
94
# The markup could be a float with multiple dots
88
95
first_dot_pos = nil
Original file line number Diff line number Diff line change 2
2
# frozen_string_literal: true
3
3
4
4
module Liquid
5
- VERSION = "5.6.1 "
5
+ VERSION = "5.6.2 "
6
6
end
Original file line number Diff line number Diff line change @@ -26,7 +26,16 @@ def test_int
26
26
def test_float
27
27
assert_template_result ( "-17.42" , "{{ -17.42 }}" )
28
28
assert_template_result ( "2.5" , "{{ 2.5 }}" )
29
+ assert_expression_result ( 0.0 , "0.....5" )
30
+ assert_expression_result ( 0.0 , "-0..1" )
29
31
assert_expression_result ( 1.5 , "1.5" )
32
+
33
+ # this is a unfortunate quirky behavior of Liquid
34
+ result = Expression . parse ( ".5" )
35
+ assert_kind_of ( Liquid ::VariableLookup , result )
36
+
37
+ result = Expression . parse ( "-.5" )
38
+ assert_kind_of ( Liquid ::VariableLookup , result )
30
39
end
31
40
32
41
def test_range
0 commit comments