Add strict2_parse to assign and capture tags#2065
Open
aswamy wants to merge 1 commit intostrict2-include-tablerowfrom
Open
Add strict2_parse to assign and capture tags#2065aswamy wants to merge 1 commit intostrict2-include-tablerowfrom
aswamy wants to merge 1 commit intostrict2-include-tablerowfrom
Conversation
Both tags previously used only regex (VariableSignature) to validate variable names, which allowed invalid identifiers like (a(b(c) and [x.y] in all parse modes. - assign: strict2_parse uses Parser to validate the LHS as a valid identifier before delegating RHS to Variable - capture: strict2_parse uses Parser to validate the variable name as a valid identifier - Both tags now include ParserSwitching and dispatch through strict_parse_with_error_mode_fallback - Lax mode is unchanged — invalid names are still accepted Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f5082d6 to
0d5c15a
Compare
graygilmore
approved these changes
Mar 26, 2026
Contributor
graygilmore
left a comment
There was a problem hiding this comment.
This all seems reasonable!
| # @liquid_syntax_keyword variable_name The name of the variable being created. | ||
| # @liquid_syntax_keyword value The value you want to assign to the variable. | ||
| class Assign < Tag | ||
| include ParserSwitching |
Contributor
There was a problem hiding this comment.
I don't think you need the include here because Tag already has it.
| # @liquid_syntax_keyword variable The name of the variable being created. | ||
| # @liquid_syntax_keyword value The value you want to assign to the variable. | ||
| class Capture < Block | ||
| include ParserSwitching |
EvilGenius13
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
strict2_parseto theassignandcapturetags so invalid variable names are rejected in strict2 mode.Both tags previously used only regex (
VariableSignature) to validate variable names across all parse modes. This allowed invalid identifiers like(a(b(c),[x.y], anda.bto be silently accepted.assign:
strict2_parseuses the regex to split on=, then validates the LHS withParser#consume(:id)+consume(:end_of_string)Variable.newas beforecapture:
strict2_parseusesParser#consume(:id)+consume(:end_of_string)to validate the variable nameBoth tags now include
ParserSwitchingand dispatch throughstrict_parse_with_error_mode_fallback. Lax mode is unchanged.Depends on: Shopify/liquid-rewriter-private#215 (rewriter changes)
Tophat
bundle install bundle exec irb -r liquid🤖 Generated with Claude Code