Correction for #723

Correction for #723
Bug was : decode failed if the password contains ```:```
release/v1.15
Mageti 2014-12-10 10:51:51 +01:00
parent 6f71632e3e
commit b7ebbb4064
1 changed files with 4 additions and 4 deletions

View File

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