CodisLabs / CodisLabs/redis-port

fix auth

Open
#64 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
634
Forks
163
PR merge metrics
No merged PRs in 30d

Description

https://github.com/CodisLabs/redis-port/blob/a2e08c1edc05bdb7a2ad0ae29369f405f77eeaa1/cmd/libs.go#L41

u.User.String()
```golang
// 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.
```patch
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, ""
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.