short-circuit parse_number with first-byte check before regex

This commit is contained in:
Tobi Lutke
2026-03-11 07:23:41 -04:00
parent d79b9fa254
commit fa412245f7
+4
View File
@@ -79,6 +79,10 @@ module Liquid
end
def parse_number(markup, ss)
# Quick reject: first byte must be digit or dash
first = markup.getbyte(0)
return false if first != DASH && (first < ZERO || first > NINE)
# check if the markup is simple integer or float
case markup
when INTEGER_REGEX