Don't stop generating fingerprint while encountering value with "=" sign (#318)

This commit is contained in:
Daniel Pintara 2019-10-31 18:02:27 +07:00 committed by Will Rouesnel
parent 27d5c9926d
commit e1428a8330
2 changed files with 5 additions and 1 deletions

View File

@ -708,7 +708,7 @@ func parseFingerprint(url string) (string, error) {
pairs := strings.Split(dsn, " ") pairs := strings.Split(dsn, " ")
kv := make(map[string]string, len(pairs)) kv := make(map[string]string, len(pairs))
for _, pair := range pairs { for _, pair := range pairs {
splitted := strings.Split(pair, "=") splitted := strings.SplitN(pair, "=", 2)
if len(splitted) != 2 { if len(splitted) != 2 {
return "", fmt.Errorf("malformed dsn %q", dsn) return "", fmt.Errorf("malformed dsn %q", dsn)
} }

View File

@ -193,6 +193,10 @@ func (s *FunctionalSuite) TestParseFingerprint(c *C) {
url: "postgresql://userDsn:passwordDsn@localhost:55432/?sslmode=disabled", url: "postgresql://userDsn:passwordDsn@localhost:55432/?sslmode=disabled",
fingerprint: "localhost:55432", fingerprint: "localhost:55432",
}, },
{
url: "postgresql://userDsn:passwordDsn%3D@localhost:55432/?sslmode=disabled",
fingerprint: "localhost:55432",
},
{ {
url: "port=1234", url: "port=1234",
fingerprint: "localhost:1234", fingerprint: "localhost:1234",