From a09a2535ca5758662dfb0577fee1644826d8a850 Mon Sep 17 00:00:00 2001 From: skratchdot Date: Thu, 19 Jun 2014 16:05:56 -0400 Subject: [PATCH] fixes #6 - (Windows) open.Start does not correctly handle URLs with ampersands --- open/exec_windows.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/open/exec_windows.go b/open/exec_windows.go index 1ed5c5f..ac44cfa 100644 --- a/open/exec_windows.go +++ b/open/exec_windows.go @@ -4,12 +4,18 @@ package open import ( "os/exec" + "strings" ) +func cleaninput(input string) string { + r := strings.NewReplacer("&", "^&") + return r.Replace(input) +} + func open(input string) *exec.Cmd { - return exec.Command("cmd", "/C", "start", "", input) + return exec.Command("cmd", "/C", "start", "", cleaninput(input)) } func openWith(input string, appName string) *exec.Cmd { - return exec.Command("cmd", "/C", "start", "", appName, input) + return exec.Command("cmd", "/C", "start", "", appName, cleaninput(input)) }