fix: fill crash on a stray '}' before a template placeholder - #1090
Open
BigDataDZ wants to merge 1 commit into
Open
fix: fill crash on a stray '}' before a template placeholder#1090BigDataDZ wants to merge 1 commit into
BigDataDZ wants to merge 1 commit into
Conversation
Signed-off-by: BigDataDZ <76271875+BigDataDZ@users.noreply.github.com>
skytin1004
approved these changes
Sep 12, 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.
Purpose of the pull request
Filling a template crashed with
java.lang.StringIndexOutOfBoundsExceptionwhenever a templatecell contained a stray
}before a{placeholder}(e.g. long prose or a JSON snippet in thesame cell as the placeholder — see #191, where the fill died with
Range [1211, 1027)).Fixes #191
What's changed?
In
ExcelWriteFillExecutor#prepareData, the closing suffix of a placeholder was searched withvalue.indexOf(FILL_SUFFIX, startIndex + 1).startIndexonly tracks how far escapedplaceholders have been consumed, so the
}search could start before the current{. A stray}preceding the{was then treated as the placeholder's suffix, inverting the bounds ofvalue.substring(prefixIndex + 1, suffixIndex).The suffix search now starts after the
{:value.indexOf(FILL_SUFFIX, Math.max(startIndex + 1, prefixIndex + 1)). A stray}is kept asliteral text (
a}b{name}fills toa}bfilled); escape handling (\{,\}) and multi-placeholdercells are unchanged.
Tests
New
FillWithStraySuffixTest(round-trip): a template cell containinga}b{name}filled with{name: "filled"}— crashes on current main, fills toa}bfilledwith this change.Checklist