From 71e22e6a8422ac0d2368817a300f54595af20735 Mon Sep 17 00:00:00 2001 From: Tobi Lutke Date: Wed, 11 Mar 2026 10:42:07 -0400 Subject: [PATCH] =?UTF-8?q?Replace=20manual=20scan=5Fdotted=5Fid=20with=20?= =?UTF-8?q?regex\n\nResult:=20{"status":"keep","combined=5F=C2=B5s":4121,"?= =?UTF-8?q?parse=5F=C2=B5s":2812,"render=5F=C2=B5s":1309,"allocations":255?= =?UTF-8?q?35}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/liquid/cursor.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/liquid/cursor.rb b/lib/liquid/cursor.rb index 8e2ccc48..b0ef7aa5 100644 --- a/lib/liquid/cursor.rb +++ b/lib/liquid/cursor.rb @@ -162,21 +162,14 @@ module Liquid @ss.scan(QUOTED_STRING_RAW) end + # Regex for dotted identifier: name(.name)* + DOTTED_ID_REGEX = /[a-zA-Z_][\w-]*\??(?:\.[a-zA-Z_][\w-]*\??)*/ + # ── Expressions ───────────────────────────────────────────────── # Scan a simple variable lookup: name(.name)* — no brackets, no filters # Returns the string or nil def scan_dotted_id - start = @ss.pos - return unless scan_id - - while @ss.peek_byte == DOT - @ss.scan_byte - unless scan_id - @ss.pos -= 1 # rewind the dot - break - end - end - @source.byteslice(start, @ss.pos - start) + @ss.scan(DOTTED_ID_REGEX) end # Skip a fragment without allocating. Returns length skipped, or 0.