fix: support powershell constrained language mode#7230
Merged
mmaietta merged 4 commits intoelectron-userland:masterfrom Nov 2, 2022
Merged
fix: support powershell constrained language mode#7230mmaietta merged 4 commits intoelectron-userland:masterfrom
mmaietta merged 4 commits intoelectron-userland:masterfrom
Conversation
🦋 Changeset detectedLatest commit: dbece13 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for car-park-attendant-cleat-11576 ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Merged
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.
Fixes #6917
In environments where PowerShell is in Constrained Language Mode,
[Convert]::ToBase64Stringand[System.Text.Encoding]::UTF8.GetByteswon't work.We're currently converting the output of
Get-AuthenticodeSignature -LiteralPath '${tempUpdateFile}' | ConvertTo-Json -Compressto base64 in powershell to get possibly non-ascii data, which would otherwise be output in the current ANSI code page. This workaround was added in #5071, FYI @orzFly @hezhuojie.I first tried setting PowerShell's
[console]::OutputEncoding, but that is also not allowed in Constrained Language Mode. So this fix is to runchcp 65001 > NULbefore running powershell.exe. See PowerShell/PowerShell#7233 for more context on this issue.In order to test that this works with non-ascii certificate subject names, I created a github release signed with a self-signed certificate with a subject name of
CN=你好at https://github.com/jeremyspiegel/electron-updater-powershell-test/releases/tag/v1.0.1. I then added the certificate to my Trusted Root Certificate Authorities and added the following test in test/src/updater/nsisUpdaterTest.ts:In order to test that this works in PowerShell Constrained Language Mode, I created a system environment variable
__PSLockDownPolicy=4and ran the above test.