fix: handle non-ASCII characters in PowerShell paths - #7793
Merged
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
📦 Release binary size reportCompares this PR's release-equivalent build against the latest published release, per OS (amd64).
🎉 Binary size shrank on at least one platform. |
PowerShell decodes native command stdout using [Console]::OutputEncoding, which defaults to the legacy OEM code page on Windows. When a path in the init bootstrap contains non-ASCII characters (e.g. a ² in the username), the UTF-8 bytes are mangled before the init script can run, breaking initialization with 'term is not recognized' errors. Quote pwsh strings containing non-ASCII runes as expandable string expressions built from [char] casts so everything written to stdout, and to the on-disk init script, is pure ASCII, which survives every code page. Elvish keeps the previous plain single-quote behavior via its own quoting function. Validated against pwsh 7.4.6 in every injection context: env var assignment, the call operator, Invoke-Expression, argument-mode --config= tokens, and the omp.ps1 executable assignment. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BCNz9G4sSmwRixkjVodcWo
JanDeDobbeleer
force-pushed
the
claude/powershell-utf8-encoding-ati5z1
branch
from
August 12, 2026 20:45
5abe227 to
648b291
Compare
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.
Prerequisites
Description
PowerShell on Windows decodes native command output using
[Console]::OutputEncoding, which defaults to the legacy OEM code page. This causes multi-byte UTF-8 sequences in stdout to be mangled before the init script can process them, breaking paths containing non-ASCII characters.This fix addresses the issue by:
Splitting
quotePwshOrElvishStrinto separate functions: CreatedquotePwshStr()for PowerShell andquoteElvishStr()for Elvish, since they have different quoting requirements.Encoding non-ASCII characters as
[char]expressions: The newquotePwshStr()function detects non-ASCII runes and emits them as PowerShell character expressions (e.g.,[char]0xB2for²,[char]::ConvertFromUtf32(0x1F4C1)for📁). This keeps the emitted code pure ASCII, which survives any code page decoding.Using expandable strings for concatenation: Non-ASCII characters are wrapped in
"$(...)"syntax to ensure proper string concatenation semantics in PowerShell.Updated all call sites: Replaced
quotePwshOrElvishStr()calls with the appropriate shell-specific function ininit.go.Test Plan
quotePwshStr()covering ASCII paths, paths with single quotes, and paths with various non-ASCII characters (U+00B2, U+00D8, U+1F4C1)TestSessionScriptPwshIsPureASCII()that verifies the entire session script output contains only ASCII bytes, even when config paths contain non-ASCII charactersquoteElvishStr()functionhttps://claude.ai/code/session_01BCNz9G4sSmwRixkjVodcWo