Skip to content

Fix tokenizer to skip closing braces inside quoted strings#2063

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

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

Conversation

@knu
Copy link
Copy Markdown
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.

@knu
Copy link
Copy Markdown
Contributor Author

knu commented May 18, 2026

I have signed the CLA!

@github-actions
Copy link
Copy Markdown

CLA: Unexpected error has occurred, please re-run the workflow.

We are sorry for the inconvenience, due to GitHub actions limitations this requires a manual intervention.

There are few ways to do it:

  • Create a new pull request with the same changes.
  • Push an empty commit to the branch.
  • Rebase the branch on top of the latest master might also help.

If the issue persists, please contact the maintainers of this repo.

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.
@knu knu force-pushed the fix-tokenizer-quoted-brace branch from c580e72 to 30cdf12 Compare May 18, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant