redis-port
redis-port copied to clipboard
fix auth
https://github.com/CodisLabs/redis-port/blob/a2e08c1edc05bdb7a2ad0ae29369f405f77eeaa1/cmd/libs.go#L41
u.User.String()
// String returns the encoded userinfo information in the standard form
// of "username[:password]".
func (u *Userinfo) String() string {
if u == nil {
return ""
}
s := escape(u.username, encodeUserPassword)
if u.passwordSet {
s += ":" + escape(u.password, encodeUserPassword)
}
return s
}
special characters will be escaped.
diff --git a/cmd/libs.go b/cmd/libs.go
index e8d6c7c..df29f80 100644
--- a/cmd/libs.go
+++ b/cmd/libs.go
@@ -38,7 +38,11 @@ func redisParsePath(path string) (addr, auth string) {
log.PanicErrorf(err, "invalid redis address %q", path)
}
if u.User != nil {
- return u.Host, u.User.String()
+ password, err := url.QueryUnescape(u.User.String())
+ if err != nil {
+ log.PanicErrorf(err, "invalid redis password %q", path)
+ }
+ return u.Host, password
} else {
return u.Host, ""
}