Skip to content

fix auth #64

@LaoQi

Description

@LaoQi

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, ""
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions