summaryrefslogtreecommitdiffstats
path: root/routers/repo/repo.go
diff options
context:
space:
mode:
authorPeter Smit <peter@smitmail.eu>2015-01-02 12:14:11 +0200
committerPeter Smit <peter@smitmail.eu>2015-01-02 12:14:11 +0200
commitd016eaaa09d5bcc1730b5d8c065511dd77e8e8bb (patch)
tree4d2d8107d9027457799d8d6c2e50200f60ed3abb /routers/repo/repo.go
parent0b56272c130c88fc4441fb1cba04657fe73efc38 (diff)
downloadgitea-d016eaaa09d5bcc1730b5d8c065511dd77e8e8bb.tar.gz
gitea-d016eaaa09d5bcc1730b5d8c065511dd77e8e8bb.zip
Fix #807 parse the userinfo with the golang tools
Note, this is now only fixed with Go version >= 1.4.2, see this bug in Go: https://github.com/golang/go/commit/07d86b1f2db73c6a0716aec4d4cd62dfacb04a21
Diffstat (limited to 'routers/repo/repo.go')
-rw-r--r--routers/repo/repo.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index 70b0c05ece..48f7b09bc0 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -6,6 +6,7 @@ package repo
import (
"fmt"
+ "net/url"
"os"
"path"
"strings"
@@ -180,11 +181,20 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
}
}
- authStr := strings.Replace(fmt.Sprintf("://%s:%s",
- form.AuthUserName, form.AuthPasswd), "@", "%40", -1)
- url := strings.Replace(form.HttpsUrl, "://", authStr+"@", 1)
+ u, err := url.Parse(form.HttpsUrl)
+
+ if err != nil || u.Scheme != "https" {
+ ctx.Data["Err_HttpsUrl"] = true
+ ctx.RenderWithErr(ctx.Tr("form.url_error"), MIGRATE, &form)
+ return
+ }
+
+ if len(form.AuthUserName) > 0 || len(form.AuthPasswd) > 0 {
+ u.User = url.UserPassword(form.AuthUserName, form.AuthPasswd)
+ }
+
repo, err := models.MigrateRepository(ctxUser, form.RepoName, form.Description, form.Private,
- form.Mirror, url)
+ form.Mirror, u.String())
if err == nil {
log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName)
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + form.RepoName)