Repository navigation
Fix raw closing tags immediately after a variable opener - #2127
Open
mehuljariwala wants to merge 2 commits into
Open
mehuljariwala wants to merge 2 commits into
mehuljariwala wants to merge 2 commits into
Conversation
Assisted-by: OpenAI Codex
Author
|
I have signed the CLA! |
|
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:
If the issue persists, please contact the maintainers of this repo. |
This branch has not been deployed
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.
Problem
When a raw block contains
{{% endraw %}}, the tokenizer consumes the closing tag together with the trailing brace as a variable token. The raw parser cannot recognize the delimiter, so it either reports an unclosed block or swallows a later raw block.For example,
{%raw%}%{{%endraw%}}{%raw%}x{%endraw%}currently renders%{{%endraw%}}{%raw%}x; with this change it renders%{}x.Fixes #2124.
Change
Recognize an
endrawtag beginning at the second brace of a variable-start token, including whitespace-control markers, and stop the token at%}. The existing raw parser can then consume the delimiter and leave trailing braces to render as text. The lookahead is limited toendrawso malformed variables such as{{%%%}}retain their existing error handling.Regression coverage checks adjacent raw blocks, multiple trailing braces, and whitespace control followed by a rendered variable. The new test fails on the original revision and passes with the fix. No dependencies added.
Validation
Ruby 4.0.6 on macOS arm64, upstream base
4e39ae4cc3da73921923c0669e0fc84a66b2f696:bundle exec ruby -Itest test/integration/tags/raw_tag_test.rb: 5 tests, 26 assertions, no failures.bundle exec rake: all three parser modes passed. Each full-suite pass ran 1,063 tests / 2,544 assertions; each additional integration pass ran 803 tests / 1,919 assertions. RuboCop inspected 160 files with no offenses.git diff --check: passed.PHASE=tokenize bundle exec ruby performance/benchmark.rb lax: upstream 2.070k iterations/s (±0.9%); patched 2.072k iterations/s (±0.9%). Each used the repository benchmark's 10-second warmup and 20-second measurement with YJIT enabled. These local runs executed concurrently, so this is a coarse comparison; no measurable regression was observed within their reported variability.The suite emits existing Ruby 4 CGI-removal and RuboCop plugin-migration warnings. No live Shopify service or browser interaction is needed for this parser change. The broader tokenizer rewrite in #2071 touches the same module; this PR provides a focused fix and regression coverage for the current implementation.
AI assistance
OpenAI Codex assisted with reproduction, implementation, and execution of the tests and benchmarks above. No independent human review is claimed. Any CLA acceptance must be completed by the contributor personally.