5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 02:49:29 +08:00

[v2, webview2loader] Prevent env and registry overrides when using the go loader (#2668)

This commit is contained in:
stffabi 2023-05-15 21:12:16 +02:00 committed by GitHub
parent c1a0e1338f
commit 22b53192e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -4,6 +4,7 @@ package webviewloader
import (
"fmt"
"os"
"path/filepath"
"syscall"
"unsafe"
@ -14,6 +15,7 @@ import (
func init() {
fmt.Println("DEB | Using go webview2loader")
preventEnvAndRegistryOverrides()
}
type webView2RunTimeType int32
@ -104,6 +106,8 @@ func createWebViewEnvironmentWithClientDll(lpLibFileName string, runtimeType web
envCompletedCom := combridge.New[iCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler](envCompletedHandler)
defer envCompletedCom.Close()
preventEnvAndRegistryOverrides()
const unknown = 1
hr, _, err := createProc.Call(
uintptr(unknown),
@ -157,3 +161,16 @@ func (r *environmentCreatedHandler) EnvironmentCompleted(errorCode HRESULT, crea
return HRESULT(windows.S_OK)
}
func preventEnvAndRegistryOverrides() {
// Setting these env variables to empty string also prevents registry overrides because webview2
// checks for existence and not for empty value
os.Setenv("WEBVIEW2_PIPE_FOR_SCRIPT_DEBUGGER", "")
os.Setenv("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "")
os.Setenv("WEBVIEW2_RELEASE_CHANNEL_PREFERENCE", "0")
// The following seems not be be required because those are only used by the webview2loader which
// in this case is implemented on our own. But nevertheless set them to empty to be consistent.
os.Setenv("WEBVIEW2_BROWSER_EXECUTABLE_FOLDER", "")
os.Setenv("WEBVIEW2_USER_DATA_FOLDER", "")
}

View File

@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Breaking Changes
- The Go WebView2Loader allowed env variable and registry overrides to change the behaviour of WebView2. This is not possible when using the native WebView2Loader with Wails and should not be possible according to [PR](https://github.com/wailsapp/wails/pull/1771). Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2668)
## v2.5.0 - 2023-05-13
### Breaking Changes