util: Prevent panic when parsing a malformed shell variable - #63446
Open
39ali wants to merge 1 commit into
Open
Conversation
SomeoneToIgnore
approved these changes
Aug 31, 2026
SomeoneToIgnore
left a comment
Contributor
There was a problem hiding this comment.
Thanks, one nit to fix and we're ready to merge.
| // If the input starts with "${", remove the trailing "}" | ||
| format!("%{}%", &var_str[..var_str.len() - 1]) | ||
| } else { | ||
| match var_str.strip_suffix('}') { | ||
| // `${SOME_VAR:-SOME_DEFAULT}`, we currently do not handle this situation, |
Contributor
There was a problem hiding this comment.
This comment belongs to input.into branch, let's keep them together.
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.
Objective
to_cmd_variableandto_powershell_variableremoved the last byte of a${...}argument assuming it was the closing brace, without checking one wasthere
Solution
Use strip_suffix('}') and pass the input through when it isn't a variable reference
Testing
added tests to cover this
To reproduce on Windows, add a context server with a malformed argument to settings.json:
Opening the agent panel and zed will crash
Release Notes:
${shell variable reference on Windows