Skip to content

Commit 848b3a6

Browse files
author
Matthew Fisher
committed
Merge pull request #64 from bacongobbler/fix-registry-parse
fix(cmd): split only twice at most
2 parents a1ee14c + 475ff66 commit 848b3a6

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

cmd/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func parseInfos(items []string) map[string]interface{} {
121121
}
122122

123123
func parseInfo(item string) (string, string, error) {
124-
parts := strings.Split(item, "=")
124+
parts := strings.SplitN(item, "=", 2)
125125

126126
if len(parts) != 2 {
127127
return "", "", fmt.Errorf(`%s is invalid, Must be in format key=value

cmd/registry_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package cmd
2+
3+
import "testing"
4+
5+
func TestParseInfo(t *testing.T) {
6+
t.Parallel()
7+
8+
// Regression test for passwords with equals signs, such as a gcr.io token
9+
key := `password=ihaveanequalssign=`
10+
if _, _, err := parseInfo(key); err != nil {
11+
t.Errorf("failed to parse valid token with equals sign: got (%s)", err)
12+
}
13+
}

0 commit comments

Comments
 (0)