Fix PowerShell encoding for Windows environment variable names - #3498
Fix PowerShell encoding for Windows environment variable names#3498vortsghost2025 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughPowerShell environment variable encoding now accepts Windows-standard names such as Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to PowerShell environment exchanges now support standard Windows variable names while rejecting names that cannot be represented safely. The focused encoding and validation coverage indicates no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 853897bfc2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if !IsValidEnvVarName(k) { | ||
| // PowerShell's braced environment-variable syntax supports Windows names | ||
| // such as ProgramFiles(x86), but a closing brace cannot be represented. | ||
| if k == "" || strings.Contains(k, "}") { |
There was a problem hiding this comment.
Reject or escape backticks in PowerShell variable names
When the environment contains an otherwise legal OS variable name with a backtick, such as FOO\``, this validation accepts it and interpolates the name directly into ${env:...}`. The PowerShell variable-name rules identify the backtick as an escape character excluded from braced variable names; in particular, a trailing backtick escapes the generated closing brace, making the token script unparsable and preventing shell initialization. Reject backticks here or escape them correctly before interpolation.
Useful? React with 👍 / 👎.
Summary
Fixes #3481.
${env:NAME}assignments for PowerShell environment variables.ProgramFiles(x86)andCommonProgramFiles(x86).}.PATHplus Windows names.Test plan
go test ./pkg/util/shellutil -count=1go test ./pkg/util/shellutil -run 'TestEncodeEnvVarsForPowerShell' -count=1