From 45f43d7ffdea60869541fe38d1e6ad61bc53282d Mon Sep 17 00:00:00 2001 From: Damian Kaczmarek Date: Thu, 9 Nov 2017 19:01:28 -0600 Subject: [PATCH] fix: escaping special characters when passing env to ssh (#104) --- plugin.go | 2 +- plugin_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin.go b/plugin.go index 3c3abb4..b40126a 100644 --- a/plugin.go +++ b/plugin.go @@ -73,7 +73,7 @@ func (p Plugin) exec(host string, wg *sync.WaitGroup, errChannel chan error) { key = strings.ToUpper(key) val := os.Getenv(key) val = strings.Replace(val, " ", "", -1) - env = append(env, key+"="+val) + env = append(env, key+"='"+val+"'") } p.Config.Script = append(env, p.Config.Script...) diff --git a/plugin_test.go b/plugin_test.go index 83c5934..246db11 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -232,7 +232,7 @@ func TestSSHCommandExitCodeError(t *testing.T) { } func TestSetENV(t *testing.T) { - os.Setenv("FOO", "1") + os.Setenv("FOO", "1)") plugin := Plugin{ Config: Config{ Host: []string{"localhost"},