]> source.dussan.org Git - gitea.git/commitdiff
Correction for #723
authorMageti <etienne@mageti.fr>
Wed, 10 Dec 2014 09:51:51 +0000 (10:51 +0100)
committerMageti <etienne@mageti.fr>
Wed, 10 Dec 2014 09:51:51 +0000 (10:51 +0100)
Correction for #723
Bug was : decode failed if the password contains ```:```

modules/base/tool.go

index 14c0e7d086727aea7539da902f88bdc19c81c1ff..39d3e8abdcfc1c59e430b8127a800bf65dbf6a7f 100644 (file)
@@ -48,11 +48,11 @@ func BasicAuthDecode(encoded string) (user string, name string, err error) {
                return user, name, err
        }
 
-       a := strings.Split(string(s), ":")
-       if len(a) == 2 {
-               user, name = a[0], a[1]
-       } else {
+       a := strings.SplitN(string(s), ":", 2)
+       if len(a) != 2 {
                err = errors.New("decode failed")
+       } else {
+               user, name = a[0], a[1]
        }
        return user, name, err
 }