mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-12 06:02:15 +09:00
* Backport #39674 * Fix form binding errors (found by #39528) * Fix #39680 --------- Co-authored-by: Roland Singer <10167163+r0l1@users.noreply.github.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
co-authored by
Roland Singer
wxiaoguang
parent
793e77b073
commit
175bc89bf9
@@ -389,6 +389,15 @@ func ComposeGoGetImport(ctx context.Context, owner, repo string) string {
|
||||
return path.Join(curAppURL.Host, setting.AppSubURL, url.PathEscape(owner), url.PathEscape(repo))
|
||||
}
|
||||
|
||||
// ComposeGoGetCloneURL returns the clone URL for the go-import meta content.
|
||||
func ComposeGoGetCloneURL(ctx *Context, owner, repo string) string {
|
||||
useSSH := setting.Repository.GoGetCloneURLProtocol == "ssh" || (setting.Repository.DisableHTTPGit && !setting.SSH.Disabled)
|
||||
if useSSH {
|
||||
return repo_model.ComposeSSHCloneURI(ctx.Doer, owner, repo)
|
||||
}
|
||||
return repo_model.ComposeHTTPSCloneURL(ctx, owner, repo)
|
||||
}
|
||||
|
||||
// EarlyResponseForGoGetMeta responses appropriate go-get meta with status 200
|
||||
// if user does not have actual access to the requested repository,
|
||||
// or the owner or repository does not exist at all.
|
||||
@@ -402,13 +411,7 @@ func EarlyResponseForGoGetMeta(ctx *Context) {
|
||||
return
|
||||
}
|
||||
|
||||
var cloneURL string
|
||||
if setting.Repository.GoGetCloneURLProtocol == "ssh" {
|
||||
cloneURL = repo_model.ComposeSSHCloneURL(ctx.Doer, username, reponame)
|
||||
} else {
|
||||
cloneURL = repo_model.ComposeHTTPSCloneURL(ctx, username, reponame)
|
||||
}
|
||||
goImportContent := fmt.Sprintf("%s git %s", ComposeGoGetImport(ctx, username, reponame), cloneURL)
|
||||
goImportContent := fmt.Sprintf("%s git %s", ComposeGoGetImport(ctx, username, reponame), ComposeGoGetCloneURL(ctx, username, reponame))
|
||||
htmlMeta := fmt.Sprintf(`<meta name="go-import" content="%s">`, html.EscapeString(goImportContent))
|
||||
ctx.PlainText(http.StatusOK, htmlMeta)
|
||||
}
|
||||
|
||||
@@ -65,6 +65,6 @@ type AdminEditUserForm struct {
|
||||
// AdminDashboardForm form for admin dashboard operations
|
||||
type AdminDashboardForm struct {
|
||||
middleware.FormDefaultValidator
|
||||
Op string `binding:"required"`
|
||||
Op string `binding:"Required"`
|
||||
From string
|
||||
}
|
||||
|
||||
@@ -571,12 +571,6 @@ type AddTimeManuallyForm struct {
|
||||
Minutes int `binding:"Range(0,1000)"`
|
||||
}
|
||||
|
||||
// SaveTopicForm form for save topics for repository
|
||||
type SaveTopicForm struct {
|
||||
middleware.FormDefaultValidator
|
||||
Topics []string `binding:"topics;Required;"`
|
||||
}
|
||||
|
||||
// AddDeployTokenForm form for adding a deploy token to a repository
|
||||
type AddDeployTokenForm struct {
|
||||
middleware.FormDefaultValidator
|
||||
|
||||
Reference in New Issue
Block a user