fix: replace non-ASCII chars in PowerShell scripts for PS 5.1 compat#2708
Closed
mnriem wants to merge 1 commit into
Closed
fix: replace non-ASCII chars in PowerShell scripts for PS 5.1 compat#2708mnriem wants to merge 1 commit into
mnriem wants to merge 1 commit into
Conversation
…ithub#2680) PowerShell 5.1 (built-in on Windows) defaults to legacy encoding when reading .ps1 files without a BOM. Multi-byte UTF-8 sequences for characters like checkmarks and em-dashes are misinterpreted, causing TerminatorExpectedAtEndOfString parse errors. Changes: - Replace Unicode symbols with ASCII equivalents in all .ps1 files (checkmark -> [OK], ballot-x -> [FAIL], em-dash -> --) - Add regression tests that scan all shipped .ps1 files for non-ASCII bytes - Fix ANSI escape code stripping in test assertions for Rich-formatted output
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses PowerShell 5.1 script parsing failures on Windows caused by non-ASCII characters being mis-decoded when .ps1 files are read without a BOM, and adds regression coverage to prevent reintroduction.
Changes:
- Replaced non-ASCII symbols (e.g.,
✓,✗, em-dash) in shipped PowerShell scripts to ensure ASCII-only content. - Updated CLI/integration tests to strip Rich ANSI escape codes before making string assertions.
- Added a regression test suite that scans shipped
.ps1files and fails on any non-ASCII bytes.
Show a summary per file
| File | Description |
|---|---|
| tests/test_ps1_encoding.py | Adds regression tests enforcing ASCII-only bytes in shipped PowerShell scripts. |
| tests/integrations/test_integration_subcommand.py | Normalizes CLI output by stripping ANSI codes before parsing/asserting table and messages. |
| tests/integrations/test_cli.py | Strips ANSI codes from captured output before assertions to avoid Rich formatting affecting tests. |
| scripts/powershell/create-new-feature.ps1 | Replaces non-ASCII em-dash in a comment for PS 5.1-safe encoding. |
| scripts/powershell/common.ps1 | Replaces Unicode status glyphs and em-dash usage to keep script content ASCII-only. |
| extensions/git/scripts/powershell/initialize-repo.ps1 | Replaces Unicode checkmark output and em-dash in comment for PS 5.1 compatibility. |
| extensions/git/scripts/powershell/git-common.ps1 | Replaces non-ASCII em-dash in comment to keep the file ASCII-only. |
| extensions/git/scripts/powershell/auto-commit.ps1 | Replaces non-ASCII em-dash in comment to keep the file ASCII-only. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 8/8 changed files
- Comments generated: 2
Collaborator
Author
|
Closing as superseded by PR #2709 (
Issue #2680 has been closed as completed. |
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
Fixes #2680
PowerShell 5.1 (built-in on Windows) defaults to the system's legacy encoding when reading
.ps1files without a BOM. Multi-byte UTF-8 sequences for characters like✓(U+2713) are misinterpreted as individual bytes, one of which gets parsed as a quote character, causingTerminatorExpectedAtEndOfStringparse errors.Changes
PowerShell script fixes (5 files)
✓→[OK]and✗→[FAIL]in string literals (common.ps1,initialize-repo.ps1)—(em-dash) →--in comments across all affected.ps1filesTest fixes (2 files)
tests/integrations/test_cli.py— applystrip_ansi()tocapsysoutput before asserting against Rich-formatted texttests/integrations/test_integration_subcommand.py— import and applystrip_ansi()to CLI output assertions affected by Rich ANSI escape codesRegression tests (1 new file)
tests/test_ps1_encoding.py— 10 parametrized tests scanning every shipped.ps1file byte-by-byte, asserting all content is ASCII-only (≤ 0x7F). Includes a discovery sanity check.Testing
✓back intocommon.ps1causes immediate test failure