-
Notifications
You must be signed in to change notification settings - Fork 7.7k
fix(powershell): ensure UTF-8 templates are written without BOM #2280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,7 +34,10 @@ New-Item -ItemType Directory -Path $paths.FEATURE_DIR -Force | Out-Null | |||||||||||||||||||||
| # Copy plan template if it exists, otherwise note it or create empty file | ||||||||||||||||||||||
| $template = Resolve-Template -TemplateName 'plan-template' -RepoRoot $paths.REPO_ROOT | ||||||||||||||||||||||
| if ($template -and (Test-Path $template)) { | ||||||||||||||||||||||
| Copy-Item $template $paths.IMPL_PLAN -Force | ||||||||||||||||||||||
| # Read the template content and write it to the implementation plan file with UTF-8 encoding without BOM | ||||||||||||||||||||||
| $content = Get-Content -Raw -Path $template | ||||||||||||||||||||||
| $Utf8NoBom = New-Object System.Text.UTF8Encoding($false) | ||||||||||||||||||||||
| [System.IO.File]::WriteAllText($paths.IMPL_PLAN, $content, $Utf8NoBom) | ||||||||||||||||||||||
|
Comment on lines
+37
to
+40
|
||||||||||||||||||||||
| # Read the template content and write it to the implementation plan file with UTF-8 encoding without BOM | |
| $content = Get-Content -Raw -Path $template | |
| $Utf8NoBom = New-Object System.Text.UTF8Encoding($false) | |
| [System.IO.File]::WriteAllText($paths.IMPL_PLAN, $content, $Utf8NoBom) | |
| # Read the template content as UTF-8 and write it to the implementation plan file with UTF-8 encoding without BOM | |
| $content = Get-Content -Raw -Encoding UTF8 -Path $template | |
| $Utf8NoBom = New-Object System.Text.UTF8Encoding($false) | |
| [System.IO.File]::WriteAllText($paths.IMPL_PLAN, $content, $Utf8NoBom) |
Copilot
AI
Apr 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[System.IO.File]::WriteAllText(...) is not indented like the rest of the if block, which makes the block harder to read and looks accidental. Please align its indentation with the surrounding statements.
| [System.IO.File]::WriteAllText($paths.IMPL_PLAN, $content, $Utf8NoBom) | |
| [System.IO.File]::WriteAllText($paths.IMPL_PLAN, $content, $Utf8NoBom) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Windows PowerShell 5.1,
Get-Contentwithout-Encodingwill treat UTF-8 without BOM as the system ANSI code page, which can corrupt non-ASCII characters in templates. Since you're normalizing output to UTF-8 no BOM, please also read the template using an explicit UTF-8 encoding (e.g.,Get-Content -Raw -Encoding UTF8or .NETReadAllText).This issue also appears on line 355 of the same file.