-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Description of Issue
When using PowerShell Universal with TwoWay Git Sync, editing and saving a script from the PSU UI can rewrite the script with a UTF-8 BOM (EF BB BF). After that sync completes, the script may still run correctly inside PSU, but external execution of the raw script content via Invoke-WebRequest | Invoke-Expression fails because the BOM contaminates the first token.
A second issue was also reproduced in the same workflow: renaming a script in PSU updates the display name in PSU, but the physical filename in the synchronized repository is not renamed.
Both behaviors were reproduced in an internal lab using the affected version listed below.
List of steps, sample code, failing test, or link to a project that reproduces the behavior.
Repro 1: BOM introduced after editing in PSU
-
Configure PSU with Git Sync:
- Mode:
TwoWay - Branch:
master - Edit mode:
Automatic - Sync interval:
1 minute
- Mode:
-
In the Git remote, create a script file such as
SampleScript.ps1with simple content like:Get-Date Write-Output "OK"
-
Allow PSU to sync and import the script.
-
Confirm the script runs:
- Inside PSU
- Externally by downloading the raw script content and piping it to
Invoke-Expression
-
Edit the script in PSU and save any small change, for example:
Get-Date Write-Output "OK2"
-
Allow the change to sync back to the Git remote.
-
Check the script bytes in the synchronized repository copy. The file now begins with:
EF BB BF -
Run the raw script content externally again:
Invoke-WebRequest <raw-script-url> | Invoke-Expression
-
The script now fails because the first token is interpreted with leading unexpected characters.
Observed behavior
- PSU execution: succeeds
- External raw-content execution via
Invoke-WebRequest | Invoke-Expression: fails after PSU save/sync - File content after PSU save includes UTF-8 BOM (
EF BB BF)
Expected behavior
- Editing and saving a script in PSU should not introduce an encoding change that breaks downstream execution scenarios.
- PSU should either preserve the existing encoding or provide a way to save without BOM when appropriate.
Repro 2: Rename does not rename physical repository file
- Create or sync a script named
SampleScript.ps1. - In PSU, rename it to
RenamedSampleScript.ps1. - Allow Git Sync to complete.
Observed behavior
- The script name shown in PSU changes.
- The physical file in the synchronized repository remains with the original filename.
Expected behavior
- Renaming a script in PSU should also rename the physical file in the synchronized repository.
Version
5.6.13
Severity
High
Hosting Method
MSI (Windows Service)
Operating System
Windows
Database
SQLite
Licensed
Yes
Features
Git Sync
Additional Environment data
Internal reproduction also validated on:
Windows 11 Pro 10.0.26200
Windows PowerShell 5.1.26100.7705
PowerShell 7.5.4
Screenshots/Animations
No response