Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix auth #64

Open
LaoQi opened this issue Jan 15, 2019 · 0 comments
Open

fix auth #64

LaoQi opened this issue Jan 15, 2019 · 0 comments

Comments

@LaoQi
Copy link

LaoQi commented Jan 15, 2019

return u.Host, u.User.String()

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, ""
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant