short-circuit parse_number with first-byte check before regex

This commit is contained in:
Tobi Lutke
2026-04-04 17:33:53 -07:00
committed by Chris Pak
parent 4c96b5f682
commit 9d9d094e20
+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