fix(textutil): make template placeholder regex non-greedy#614
Open
adityagiri3600 wants to merge 3 commits intostackql:mainfrom
Open
fix(textutil): make template placeholder regex non-greedy#614adityagiri3600 wants to merge 3 commits intostackql:mainfrom
adityagiri3600 wants to merge 3 commits intostackql:mainfrom
Conversation
Contributor
|
@adityagiri3600 cheers for the contribution. Please add a couple of go tests to verify the behaviour is unchanged for simple input and as desired for more complex |
Author
|
will do! |
Contributor
|
@adityagiri3600 good progress. Please amend so that the linter passes now: https://github.com/stackql/stackql/actions/runs/21864103894/job/63119969601 Thanks again |
Author
|
@general-kroll-4-life Fixed now, and apologies for missing that in my first pass. Thanks! |
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.
Description
Fixes placeholder matching in textutil.GetTemplateLikeString by switching from a greedy regex to a non-greedy regex.
GetTemplateLikeString is intended to normalize template placeholders
{{...}}so matching can work on the surrounding literal text.Using a greedy pattern
{{.*}}can consume from the first {{ to the last }} when multiple placeholders exist in one string, collapsing distinct placeholders into one match.Switching to non-greedy
{{.*?}}ensures each placeholder is replaced independently, which preserves expected behavior for multi-placeholder inputs.Example:
Input:
prefix {{one}} middle {{two}} suffixGreedy
{{.*}}matches:{{one}} middle {{two}}Non-greedy
{{.*?}}matches:{{one}}and{{two}}Type of change
Issues referenced.
None
Evidence
Local command run:
go test ./pkg/textutilResult: pass (
[no test files], package compiles successfully)Checklist:
Variations
This is a one-line, non-breaking regex correction in textutil.go with no interface or behavior changes beyond fixing greedy matching for multi-placeholder strings.
I ran a targeted package test (
go test ./pkg/textutil) as lightweight evidence for this minimal change.I did not run full unit/robot/lint suites for this tiny scoped fix.
Tech Debt
No technical debt introduced by this change set.