diff --git a/internal/ingress/block_handler.go b/internal/ingress/block_handler.go index dc6c83ca..1843ba44 100644 --- a/internal/ingress/block_handler.go +++ b/internal/ingress/block_handler.go @@ -40,9 +40,8 @@ func showBlockedModal(event BlockEvent, ingressAddress string) { "--package-id", event.Artifact.PackageName, "--package-version", event.Artifact.PackageVersion, "--package-human-name", event.Artifact.DisplayName, - // Encapsulate title as an argument: It can contain spaces causing the argument parsing to fail for windows. - "--title", fmt.Sprintf("\"%s\"", title), - "--subtitle", fmt.Sprintf("\"%s\"", subtitle), + "--title", title, + "--subtitle", subtitle, "--ingress", ingressAddress, "--bypass-enabled=true", } diff --git a/internal/platform/platform_windows_helpers.go b/internal/platform/platform_windows_helpers.go index d738a0e5..958d7cbe 100644 --- a/internal/platform/platform_windows_helpers.go +++ b/internal/platform/platform_windows_helpers.go @@ -6,6 +6,7 @@ import ( "context" "fmt" "log" + "syscall" "strings" "unsafe" @@ -69,12 +70,13 @@ func getLoggedInUserSIDs(ctx context.Context) ([]string, error) { } func buildCommandLineForWindowsProcess(binaryPath string, args []string) *uint16 { - cmdLine := binaryPath - if len(args) > 0 { - cmdLine = fmt.Sprintf(`"%s" %s`, binaryPath, strings.Join(args, " ")) - } else { - cmdLine = fmt.Sprintf(`"%s"`, binaryPath) + escapedArgs := make([]string, 0, len(args)+1) + escapedArgs = append(escapedArgs, syscall.EscapeArg(binaryPath)) + for _, arg := range args { + escapedArgs = append(escapedArgs, syscall.EscapeArg(arg)) } + + cmdLine := strings.Join(escapedArgs, " ") cmdLinePtr, err := windows.UTF16PtrFromString(cmdLine) if err != nil { return nil @@ -106,8 +108,7 @@ func runProcessAsUser(duplicatedToken windows.Token, cmdLinePtr *uint16, envBloc var si windows.StartupInfo si.Cb = uint32(unsafe.Sizeof(si)) si.Desktop, _ = windows.UTF16PtrFromString("winsta0\\default") - si.Flags = windows.STARTF_USESTDHANDLES | windows.STARTF_USESHOWWINDOW - si.ShowWindow = uint16(windows.SW_HIDE) + si.Flags = windows.STARTF_USESTDHANDLES si.StdOutput = stdoutWrite si.StdErr = stdoutWrite