From b7ebbb4064942ca5013207eb89c4e2dd045ba3ce Mon Sep 17 00:00:00 2001
From: Mageti <etienne@mageti.fr>
Date: Wed, 10 Dec 2014 10:51:51 +0100
Subject: [PATCH 1/2] Correction for #723

Correction for #723
Bug was : decode failed if the password contains ```:```
---
 modules/base/tool.go | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/base/tool.go b/modules/base/tool.go
index 14c0e7d086..39d3e8abdc 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -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
 }

From e321469884c6a775fc0b639d276234daed1ef591 Mon Sep 17 00:00:00 2001
From: Mageti <etienne@mageti.fr>
Date: Wed, 10 Dec 2014 11:01:17 +0100
Subject: [PATCH 2/2] remove unused code in BasicAuthDecode

---
 modules/base/tool.go | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/modules/base/tool.go b/modules/base/tool.go
index 39d3e8abdc..3c435fbdb1 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -48,13 +48,8 @@ func BasicAuthDecode(encoded string) (user string, name string, err error) {
 		return user, name, err
 	}
 
-	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
+	auth := strings.SplitN(string(s), ":", 2)
+	return auth[0], auth[1], err
 }
 
 func BasicAuthEncode(username, password string) string {