From 0924e59840a57ca5156fe387477ab99dbc691aab Mon Sep 17 00:00:00 2001 From: Tobi Lutke Date: Wed, 11 Mar 2026 10:41:44 -0400 Subject: [PATCH] =?UTF-8?q?Replace=20manual=20scan=5Fquoted=5Fstring=20wit?= =?UTF-8?q?h=20regex=20capture=20groups\n\nResult:=20{"status":"keep","com?= =?UTF-8?q?bined=5F=C2=B5s":4102,"parse=5F=C2=B5s":2849,"render=5F=C2=B5s"?= =?UTF-8?q?:1253,"allocations":25535}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/liquid/cursor.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/liquid/cursor.rb b/lib/liquid/cursor.rb index 5ec82876..8e2ccc48 100644 --- a/lib/liquid/cursor.rb +++ b/lib/liquid/cursor.rb @@ -142,19 +142,16 @@ module Liquid end end + # Regex for quoted string content (without quotes) + SINGLE_QUOTED_CONTENT = /'([^']*)'/ + DOUBLE_QUOTED_CONTENT = /"([^"]*)"/ + # ── Strings ───────────────────────────────────────────────────── # Scan a quoted string ('...' or "..."). Returns the content without quotes, or nil. def scan_quoted_string - b = @ss.peek_byte - return unless b == QUOTE_S || b == QUOTE_D - - quote = b - @ss.scan_byte - start = @ss.pos - @ss.scan_byte while (b = @ss.peek_byte) && b != quote - content = @source.byteslice(start, @ss.pos - start) - @ss.scan_byte if @ss.peek_byte == quote # consume closing quote - content + if @ss.scan(SINGLE_QUOTED_CONTENT) || @ss.scan(DOUBLE_QUOTED_CONTENT) + @ss[1] + end end # Regex for quoted strings (single or double quoted, including quotes)