Repository navigation
End an unclosed block in {% liquid %} at its last line - #1357
Merged
Merged
Conversation
With allowUnclosedDocumentNode, a block in {% liquid %} that's never
closed was given the position of an end tag at the end of the last
line: blockEndPosition ran from there for the length of "end" and the
tag name, so it and the block's position went past the end of the
template.
It's now empty, at the end of the last line, as for an unclosed block
outside {% liquid %}.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clauderic
added this pull request to stack #1358
October 21, 2026 00:29
This was referenced Oct 21, 2026
clauderic
removed this pull request from stack #1358
October 21, 2026 00:47
clauderic
added this pull request to stack #1360
October 21, 2026 00:48
charlespwd
approved these changes
Oct 23, 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.
What are you adding in this PR?
When unclosed blocks are allowed, as in
toLiquidASTand the tolerant parses, a block in{% liquid %}that's never closed got the position of an end tag after its last line:{%- liquid assign var1 = product if use_variant assign var2 = var1 -%}if'sblockEndPositionstarted at the end of the last line and ran for the length ofendif, over\n-%}and one character past the end of the 78-character template. Itspositionended there too.<div>{% liquid … %}</div>, it covered\n%}</d.{% liquid %}. Theifcoversif use_varianttovar1.The test of this template now checks where the
ifends. Every other test passes unchanged, and prettier formats these templates the same as before.What's next? Any followup issues?
#1347 is stacked on this. #1359, the parser specs, on top of #1347, needs this fix: a spec gives a position as the text it covers, cut out of the template, and this one ran past its end.
Tophatting
npx vitest run packages/liquid-html-parser/src/document/parser.test.tstoLiquidASTthe template above. Before,children[0].markup[1].blockEndPositionwas{ start: 74, end: 79 }; now it's{ start: 74, end: 74 }.Before you deploy
changeset🤖 Generated with Claude Code