diff --git a/AUTHORS b/AUTHORS index 0491c4c64..7d10c7c99 100644 --- a/AUTHORS +++ b/AUTHORS @@ -110,6 +110,7 @@ Xiangyu Hu Xiaobing Jiang Xiuming Chen Xuehong Chan +Zhang Xiang Zhenye Xie Zhixin Wen Ziheng Lyu @@ -128,6 +129,7 @@ InfoSum Ltd. Keybase Inc. Multiplay Ltd. Percona LLC +PingCAP Inc. Pivotal Inc. Shattered Silicon Ltd. Stripe Inc. diff --git a/README.md b/README.md index fff8969f3..ac79890a7 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ A MySQL-Driver for Go's [database/sql](https://golang.org/pkg/database/sql/) pac ## Installation Simple install the package to your [$GOPATH](https://github.com/golang/go/wiki/GOPATH "GOPATH") with the [go tool](https://golang.org/cmd/go/ "go command") from shell: ```bash -$ go get -u github.com/go-sql-driver/mysql +go get -u github.com/go-sql-driver/mysql ``` Make sure [Git is installed](https://git-scm.com/downloads) on your machine and in your system's `PATH`. diff --git a/driver_test.go b/driver_test.go index 39aed8355..5bf8dd40c 100644 --- a/driver_test.go +++ b/driver_test.go @@ -3394,15 +3394,14 @@ func TestConnectionAttributes(t *testing.T) { host, } - customAttrs := []string{"attr1", "attr2"} - customAttrValues := []string{"foo", "bar"} + customAttrs := []string{"attr1", "fo/o"} + customAttrValues := []string{"value1", "bo/o"} customAttrStrs := make([]string, len(customAttrs)) for i := range customAttrs { customAttrStrs[i] = fmt.Sprintf("%s:%s", customAttrs[i], customAttrValues[i]) } - - dsn += fmt.Sprintf("&connectionAttributes=%s", strings.Join(customAttrStrs, ",")) + dsn += "&connectionAttributes=" + url.QueryEscape(strings.Join(customAttrStrs, ",")) var db *sql.DB if _, err := ParseDSN(dsn); err != errInvalidDSNUnsafeCollation { @@ -3430,7 +3429,7 @@ func TestConnectionAttributes(t *testing.T) { expectedAttrValues := append(append([]string{}, defaultAttrValues...), customAttrValues...) for i := range connAttrs { if gotValue := rowsMap[connAttrs[i]]; gotValue != expectedAttrValues[i] { - dbt.Errorf("expected %s, got %s", expectedAttrValues[i], gotValue) + dbt.Errorf("expected %q, got %q", expectedAttrValues[i], gotValue) } } } diff --git a/dsn.go b/dsn.go index 50c7ec413..ef0608636 100644 --- a/dsn.go +++ b/dsn.go @@ -569,7 +569,11 @@ func parseDSNParams(cfg *Config, params string) (err error) { // Connection attributes case "connectionAttributes": - cfg.ConnectionAttributes = value + connectionAttributes, err := url.QueryUnescape(value) + if err != nil { + return fmt.Errorf("invalid connectionAttributes value: %v", err) + } + cfg.ConnectionAttributes = connectionAttributes default: // lazy init