Skip to content

Fix tokenizer to skip closing braces inside quoted strings#2063

Open
knu wants to merge 1 commit intoShopify:mainfrom
knu:fix-tokenizer-quoted-brace
Open

Fix tokenizer to skip closing braces inside quoted strings#2063
knu wants to merge 1 commit intoShopify:mainfrom
knu:fix-tokenizer-quoted-brace

Conversation

@knu
Copy link
Contributor

@knu knu commented Mar 20, 2026

The byte-scanning tokenizer does not account for quoted strings when scanning for }} to terminate a variable token. A } inside a quoted filter argument prematurely ends the token, causing a SyntaxError.

For example, the following valid template fails to parse:

{{ message | replace: "{name}", customer_name }}

This patch makes next_variable_token skip over single- and double-quoted strings so that their contents do not interfere with }} detection.

The byte-scanning tokenizer does not account for quoted strings when
scanning for `}}` to terminate a variable token.  A `}` inside a
quoted filter argument prematurely ends the token, causing a
SyntaxError.

For example, the following valid template fails to parse:

    {{ message | replace: "{name}", customer_name }}

This patch makes `next_variable_token` skip over single- and
double-quoted strings so that their contents do not interfere with
`}}` detection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant