From 06de2e587d63f8af4dafaf6281496182a0acf0c9 Mon Sep 17 00:00:00 2001 From: Regan Chan Date: Tue, 30 Jan 2018 15:17:46 -0500 Subject: [PATCH] Allow values in key/value pairs to contain '=' characters --- drone/internal/util.go | 2 +- drone/internal/util_test.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drone/internal/util.go b/drone/internal/util.go index b45d5f7b..a25181d4 100644 --- a/drone/internal/util.go +++ b/drone/internal/util.go @@ -87,7 +87,7 @@ func ParseRepo(str string) (user, repo string, err error) { func ParseKeyPair(p []string) map[string]string { params := map[string]string{} for _, i := range p { - parts := strings.Split(i, "=") + parts := strings.SplitN(i, "=", 2) if len(parts) != 2 { continue } diff --git a/drone/internal/util_test.go b/drone/internal/util_test.go index 41baa6db..571c1042 100644 --- a/drone/internal/util_test.go +++ b/drone/internal/util_test.go @@ -3,11 +3,14 @@ package internal import "testing" func TestParseKeyPair(t *testing.T) { - s := []string{"FOO=bar", "BAR=", "INVALID"} + s := []string{"FOO=bar", "BAR=", "BAZ=qux=quux", "INVALID"} p := ParseKeyPair(s) if p["FOO"] != "bar" { t.Errorf("Wanted %q, got %q.", "bar", p["FOO"]) } + if p["BAZ"] != "qux=quux" { + t.Errorf("Wanted %q, got %q.", "qux=quux", p["BAZ"]) + } if _, exists := p["BAR"]; !exists { t.Error("Missing a key with no value. Keys with empty values are also valid.") }