fix(rewrite): preserve quoted assignment data - #3462
Open
zhiwuyazhe-fjr wants to merge 1 commit into
Open
Conversation
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.
Summary
shellcheckcorruption, single- and double-quoted assignment data, and real commands outside the quoted valueRoot cause
The lexer kept the quote boundaries and byte offsets correctly. The corruption happened later in
ENV_PREFIX: when a complete quoted assignment did not satisfy the trailing-whitespace requirement at a compound-command boundary, the regex could fall back to the broad unquoted alternative and match onlyD='#. The remaining literal text then began withshellcheckand was rewritten as a command.The unquoted fragment now excludes quote characters, while the environment value accepts a sequence of complete quoted or unquoted fragments. This prevents partial reinterpretation without regressing valid forms such as
FOO='bar baz'qux git status.This is independent of #3202's case-terminator lexer fix.
Security behavior
The original #3262 payload now passes through unchanged. A supported command outside the quoted assignment is still rewritten:
Test plan
D='# rtk shellcheck ...'before the fixcargo fmt --all -- --checkcargo clippy --all-targetscargo test --all: 2574 passed, 0 failed, 8 ignoredrtk hook claudeverification:cargo test: quoted bytes preserved, command rewrittenCloses #3262