mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-30 05:07:06 +08:00
Merge pull request #822 from phsmit/fix_807
Fix #807 parse the userinfo with the golang tools
This commit is contained in:
commit
edbfbfa66e
|
@ -6,6 +6,7 @@ package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -180,11 +181,20 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
authStr := strings.Replace(fmt.Sprintf("://%s:%s",
|
u, err := url.Parse(form.HttpsUrl)
|
||||||
form.AuthUserName, form.AuthPasswd), "@", "%40", -1)
|
|
||||||
url := strings.Replace(form.HttpsUrl, "://", authStr+"@", 1)
|
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,
|
repo, err := models.MigrateRepository(ctxUser, form.RepoName, form.Description, form.Private,
|
||||||
form.Mirror, url)
|
form.Mirror, u.String())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName)
|
log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName)
|
||||||
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + form.RepoName)
|
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + form.RepoName)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user