fix(substitution): a suggestion containing PIPE was corrupted - #1146
Closed
VXNCXNX wants to merge 1 commit into
Closed
fix(substitution): a suggestion containing PIPE was corrupted#1146VXNCXNX wants to merge 1 commit into
VXNCXNX wants to merge 1 commit into
Conversation
getOptions swapped escaped pipes for the literal string PIPE before splitting, then swapped back, so a swap value of PIPELINE came out as |LINE. Scan for unescaped pipes instead of round-tripping a sentinel.
Member
|
Thanks — but the |
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.
A
substitutionsuggestion containing the lettersPIPEcomes out mangled.swap: {pipeline: PIPELINE}on the textThe pipeline is here.:So the
replaceaction offers to insert|LINE, which is not what the rule author wrote.Cause
getOptionsprotected escaped pipes by round-tripping through a sentinel:The sentinel is ordinary text a user can legitimately suggest, so the second
ReplaceAllrewrites their own content.PIPE,PIPELINE,PIPELININGare all affected.The fix
Scan for unescaped
|instead of substituting a placeholder. No sentinel means nothing to collide with. The existingTODOaboutregexp2lacking.Splitis why the helper is hand-rolled either way, so this does not add a workaround, it replaces one that could corrupt data with one that cannot.Escaping still works: a swap of
A\|Bstill yieldsA|B, verified on the built binary.Verification
Three cases added to
TestOptionsininternal/check/substitution_test.go:PIPELINEalone,PIPELINE|conduit(sentinel text plus a real split), andPIPE\|LINE(sentinel text plus an escaped pipe).Reverting only the split back to the sentinel version fails it:
go build ./...,gofmt -landgo test ./...are clean, including thee2eandlintpackages.Disclosure: written with AI assistance (Claude Code). I built binaries before and after and produced the JSON output above by running them, checked that escaped pipes still resolve, and ran the mutation check myself.