diff options
author | 6543 <6543@obermui.de> | 2021-08-11 02:31:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-11 02:31:13 +0200 |
commit | c4d70a032564f610b7215d3d3973943abbc7395f (patch) | |
tree | 2aa8fe44a1b4d0251a18ae671509d4f2439ed85d /routers/web/repo | |
parent | 2eeae4edb685b22e926d301465d771fe7a0b0c83 (diff) | |
download | gitea-c4d70a032564f610b7215d3d3973943abbc7395f.tar.gz gitea-c4d70a032564f610b7215d3d3973943abbc7395f.zip |
Rename ctx.Form() to ctx.FormString() and move code into own file (#16571)
Followup from #16562 prepare for #16567
* Rename ctx.Form() to ctx.FormString()
* Reimplement FormX func to need less code and cpu cycles
* Move code into own file
Diffstat (limited to 'routers/web/repo')
-rw-r--r-- | routers/web/repo/attachment.go | 2 | ||||
-rw-r--r-- | routers/web/repo/branch.go | 4 | ||||
-rw-r--r-- | routers/web/repo/commit.go | 2 | ||||
-rw-r--r-- | routers/web/repo/compare.go | 6 | ||||
-rw-r--r-- | routers/web/repo/http.go | 4 | ||||
-rw-r--r-- | routers/web/repo/issue.go | 46 | ||||
-rw-r--r-- | routers/web/repo/issue_label.go | 8 | ||||
-rw-r--r-- | routers/web/repo/lfs.go | 6 | ||||
-rw-r--r-- | routers/web/repo/middlewares.go | 4 | ||||
-rw-r--r-- | routers/web/repo/migrate.go | 20 | ||||
-rw-r--r-- | routers/web/repo/milestone.go | 6 | ||||
-rw-r--r-- | routers/web/repo/pull.go | 4 | ||||
-rw-r--r-- | routers/web/repo/pull_review.go | 4 | ||||
-rw-r--r-- | routers/web/repo/release.go | 2 | ||||
-rw-r--r-- | routers/web/repo/repo.go | 6 | ||||
-rw-r--r-- | routers/web/repo/search.go | 6 | ||||
-rw-r--r-- | routers/web/repo/setting.go | 10 | ||||
-rw-r--r-- | routers/web/repo/setting_protected_branch.go | 4 | ||||
-rw-r--r-- | routers/web/repo/topic.go | 2 | ||||
-rw-r--r-- | routers/web/repo/view.go | 2 |
20 files changed, 74 insertions, 74 deletions
diff --git a/routers/web/repo/attachment.go b/routers/web/repo/attachment.go index a57cf633e6..1a25384792 100644 --- a/routers/web/repo/attachment.go +++ b/routers/web/repo/attachment.go @@ -71,7 +71,7 @@ func uploadAttachment(ctx *context.Context, allowedTypes string) { // DeleteAttachment response for deleting issue's attachment func DeleteAttachment(ctx *context.Context) { - file := ctx.Form("file") + file := ctx.FormString("file") attach, err := models.GetAttachmentByUUID(file) if err != nil { ctx.Error(http.StatusBadRequest, err.Error()) diff --git a/routers/web/repo/branch.go b/routers/web/repo/branch.go index f89a5543c1..84c3864669 100644 --- a/routers/web/repo/branch.go +++ b/routers/web/repo/branch.go @@ -84,7 +84,7 @@ func Branches(ctx *context.Context) { // DeleteBranchPost responses for delete merged branch func DeleteBranchPost(ctx *context.Context) { defer redirect(ctx) - branchName := ctx.Form("name") + branchName := ctx.FormString("name") if err := repo_service.DeleteBranch(ctx.User, ctx.Repo.Repository, ctx.Repo.GitRepo, branchName); err != nil { switch { @@ -113,7 +113,7 @@ func RestoreBranchPost(ctx *context.Context) { defer redirect(ctx) branchID := ctx.FormInt64("branch_id") - branchName := ctx.Form("name") + branchName := ctx.FormString("name") deletedBranch, err := ctx.Repo.Repository.GetDeletedBranchByID(branchID) if err != nil { diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index e1d93a2435..57ee7a2043 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -177,7 +177,7 @@ func SearchCommits(ctx *context.Context) { ctx.Data["PageIsCommits"] = true ctx.Data["PageIsViewCode"] = true - query := strings.Trim(ctx.Form("q"), " ") + query := strings.Trim(ctx.FormString("q"), " ") if len(query) == 0 { ctx.Redirect(ctx.Repo.RepoLink + "/commits/" + ctx.Repo.BranchNameSubURL()) return diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 511a74cdd5..ec65813656 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -700,9 +700,9 @@ func ExcerptBlob(ctx *context.Context) { idxRight := ctx.FormInt("right") leftHunkSize := ctx.FormInt("left_hunk_size") rightHunkSize := ctx.FormInt("right_hunk_size") - anchor := ctx.Form("anchor") - direction := ctx.Form("direction") - filePath := ctx.Form("path") + anchor := ctx.FormString("anchor") + direction := ctx.FormString("direction") + filePath := ctx.FormString("path") gitRepo := ctx.Repo.GitRepo chunkSize := gitdiff.BlobExcerptChunkSize commit, err := gitRepo.GetCommit(commitID) diff --git a/routers/web/repo/http.go b/routers/web/repo/http.go index 82bf039c0d..6078d764b6 100644 --- a/routers/web/repo/http.go +++ b/routers/web/repo/http.go @@ -70,13 +70,13 @@ func httpBase(ctx *context.Context) (h *serviceHandler) { username := ctx.Params(":username") reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git") - if ctx.Form("go-get") == "1" { + if ctx.FormString("go-get") == "1" { context.EarlyResponseForGoGetMeta(ctx) return } var isPull, receivePack bool - service := ctx.Form("service") + service := ctx.FormString("service") if service == "git-receive-pack" || strings.HasSuffix(ctx.Req.URL.Path, "git-receive-pack") { isPull = false diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 724ce5c774..248ae5b132 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -110,8 +110,8 @@ func MustAllowPulls(ctx *context.Context) { func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption util.OptionalBool) { var err error - viewType := ctx.Form("type") - sortType := ctx.Form("sort") + viewType := ctx.FormString("type") + sortType := ctx.FormString("sort") types := []string{"all", "your_repositories", "assigned", "created_by", "mentioned", "review_requested"} if !util.IsStringInSlice(viewType, types, true) { viewType = "all" @@ -140,7 +140,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti repo := ctx.Repo.Repository var labelIDs []int64 - selectLabels := ctx.Form("labels") + selectLabels := ctx.FormString("labels") if len(selectLabels) > 0 && selectLabels != "0" { labelIDs, err = base.StringsToInt64s(strings.Split(selectLabels, ",")) if err != nil { @@ -149,7 +149,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti } } - keyword := strings.Trim(ctx.Form("q"), " ") + keyword := strings.Trim(ctx.FormString("q"), " ") if bytes.Contains([]byte(keyword), []byte{0x00}) { keyword = "" } @@ -187,9 +187,9 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti } } - isShowClosed := ctx.Form("state") == "closed" + isShowClosed := ctx.FormString("state") == "closed" // if open issues are zero and close don't, use closed as default - if len(ctx.Form("state")) == 0 && issueStats.OpenCount == 0 && issueStats.ClosedCount != 0 { + if len(ctx.FormString("state")) == 0 && issueStats.OpenCount == 0 && issueStats.ClosedCount != 0 { isShowClosed = true } @@ -285,7 +285,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti } if repo.Owner.IsOrganization() { - orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.Form("sort"), models.ListOptions{}) + orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.FormString("sort"), models.ListOptions{}) if err != nil { ctx.ServerError("GetLabelsByOrgID", err) return @@ -380,7 +380,7 @@ func Issues(ctx *context.Context) { // Get milestones ctx.Data["Milestones"], err = models.GetMilestones(models.GetMilestonesOption{ RepoID: ctx.Repo.Repository.ID, - State: api.StateType(ctx.Form("state")), + State: api.StateType(ctx.FormString("state")), }) if err != nil { ctx.ServerError("GetAllRepoMilestones", err) @@ -655,7 +655,7 @@ func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository, isPull boo } ctx.Data["Labels"] = labels if repo.Owner.IsOrganization() { - orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.Form("sort"), models.ListOptions{}) + orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.FormString("sort"), models.ListOptions{}) if err != nil { return nil } @@ -719,9 +719,9 @@ func getFileContentFromDefaultBranch(ctx *context.Context, filename string) (str func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleDirs []string, possibleFiles []string) { templateCandidates := make([]string, 0, len(possibleFiles)) - if ctx.Form("template") != "" { + if ctx.FormString("template") != "" { for _, dirName := range possibleDirs { - templateCandidates = append(templateCandidates, path.Join(dirName, ctx.Form("template"))) + templateCandidates = append(templateCandidates, path.Join(dirName, ctx.FormString("template"))) } } templateCandidates = append(templateCandidates, possibleFiles...) // Append files to the end because they should be fallback @@ -741,7 +741,7 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleDirs [ if repoLabels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, "", models.ListOptions{}); err == nil { ctx.Data["Labels"] = repoLabels if ctx.Repo.Owner.IsOrganization() { - if orgLabels, err := models.GetLabelsByOrgID(ctx.Repo.Owner.ID, ctx.Form("sort"), models.ListOptions{}); err == nil { + if orgLabels, err := models.GetLabelsByOrgID(ctx.Repo.Owner.ID, ctx.FormString("sort"), models.ListOptions{}); err == nil { ctx.Data["OrgLabels"] = orgLabels repoLabels = append(repoLabels, orgLabels...) } @@ -773,9 +773,9 @@ func NewIssue(ctx *context.Context) { ctx.Data["RequireSimpleMDE"] = true ctx.Data["RequireTribute"] = true ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes - title := ctx.Form("title") + title := ctx.FormString("title") ctx.Data["TitleQuery"] = title - body := ctx.Form("body") + body := ctx.FormString("body") ctx.Data["BodyQuery"] = body ctx.Data["IsProjectsEnabled"] = ctx.Repo.CanRead(models.UnitTypeProjects) @@ -1174,7 +1174,7 @@ func ViewIssue(ctx *context.Context) { ctx.Data["Labels"] = labels if repo.Owner.IsOrganization() { - orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.Form("sort"), models.ListOptions{}) + orgLabels, err := models.GetLabelsByOrgID(repo.Owner.ID, ctx.FormString("sort"), models.ListOptions{}) if err != nil { ctx.ServerError("GetLabelsByOrgID", err) return @@ -1624,7 +1624,7 @@ func checkIssueRights(ctx *context.Context, issue *models.Issue) { } func getActionIssues(ctx *context.Context) []*models.Issue { - commaSeparatedIssueIDs := ctx.Form("issue_ids") + commaSeparatedIssueIDs := ctx.FormString("issue_ids") if len(commaSeparatedIssueIDs) == 0 { return nil } @@ -1722,7 +1722,7 @@ func UpdateIssueContent(ctx *context.Context) { return } - content := ctx.Form("content") + content := ctx.FormString("content") if err := issue_service.ChangeContent(issue, ctx.User, content); err != nil { ctx.ServerError("ChangeContent", err) return @@ -1735,7 +1735,7 @@ func UpdateIssueContent(ctx *context.Context) { } content, err := markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.Form("context"), + URLPrefix: ctx.FormString("context"), Metas: ctx.Repo.Repository.ComposeMetas(), GitRepo: ctx.Repo.GitRepo, }, issue.Content) @@ -1783,7 +1783,7 @@ func UpdateIssueAssignee(ctx *context.Context) { } assigneeID := ctx.FormInt64("id") - action := ctx.Form("action") + action := ctx.FormString("action") for _, issue := range issues { switch action { @@ -1829,7 +1829,7 @@ func UpdatePullReviewRequest(ctx *context.Context) { } reviewID := ctx.FormInt64("id") - action := ctx.Form("action") + action := ctx.FormString("action") // TODO: Not support 'clear' now if action != "attach" && action != "detach" { @@ -1954,7 +1954,7 @@ func UpdateIssueStatus(ctx *context.Context) { } var isClosed bool - switch action := ctx.Form("action"); action { + switch action := ctx.FormString("action"); action { case "open": isClosed = false case "close": @@ -2145,7 +2145,7 @@ func UpdateCommentContent(ctx *context.Context) { } oldContent := comment.Content - comment.Content = ctx.Form("content") + comment.Content = ctx.FormString("content") if len(comment.Content) == 0 { ctx.JSON(http.StatusOK, map[string]interface{}{ "content": "", @@ -2164,7 +2164,7 @@ func UpdateCommentContent(ctx *context.Context) { } content, err := markdown.RenderString(&markup.RenderContext{ - URLPrefix: ctx.Form("context"), + URLPrefix: ctx.FormString("context"), Metas: ctx.Repo.Repository.ComposeMetas(), GitRepo: ctx.Repo.GitRepo, }, comment.Content) diff --git a/routers/web/repo/issue_label.go b/routers/web/repo/issue_label.go index 4ce8e17e1b..abb529649a 100644 --- a/routers/web/repo/issue_label.go +++ b/routers/web/repo/issue_label.go @@ -53,7 +53,7 @@ func InitializeLabels(ctx *context.Context) { // RetrieveLabels find all the labels of a repository and organization func RetrieveLabels(ctx *context.Context) { - labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Form("sort"), models.ListOptions{}) + labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.FormString("sort"), models.ListOptions{}) if err != nil { ctx.ServerError("RetrieveLabels.GetLabels", err) return @@ -66,7 +66,7 @@ func RetrieveLabels(ctx *context.Context) { ctx.Data["Labels"] = labels if ctx.Repo.Owner.IsOrganization() { - orgLabels, err := models.GetLabelsByOrgID(ctx.Repo.Owner.ID, ctx.Form("sort"), models.ListOptions{}) + orgLabels, err := models.GetLabelsByOrgID(ctx.Repo.Owner.ID, ctx.FormString("sort"), models.ListOptions{}) if err != nil { ctx.ServerError("GetLabelsByOrgID", err) return @@ -93,7 +93,7 @@ func RetrieveLabels(ctx *context.Context) { } } ctx.Data["NumLabels"] = len(labels) - ctx.Data["SortType"] = ctx.Form("sort") + ctx.Data["SortType"] = ctx.FormString("sort") } // NewLabel create new label for repository @@ -165,7 +165,7 @@ func UpdateIssueLabel(ctx *context.Context) { return } - switch action := ctx.Form("action"); action { + switch action := ctx.FormString("action"); action { case "clear": for _, issue := range issues { if err := issue_service.ClearLabels(issue, ctx.User); err != nil { diff --git a/routers/web/repo/lfs.go b/routers/web/repo/lfs.go index e41319d71e..e524a9209a 100644 --- a/routers/web/repo/lfs.go +++ b/routers/web/repo/lfs.go @@ -195,7 +195,7 @@ func LFSLockFile(ctx *context.Context) { ctx.NotFound("LFSLocks", nil) return } - originalPath := ctx.Form("path") + originalPath := ctx.FormString("path") lockPath := originalPath if len(lockPath) == 0 { ctx.Flash.Error(ctx.Tr("repo.settings.lfs_invalid_locking_path", originalPath)) @@ -366,13 +366,13 @@ func LFSFileFind(ctx *context.Context) { ctx.NotFound("LFSFind", nil) return } - oid := ctx.Form("oid") + oid := ctx.FormString("oid") size := ctx.FormInt64("size") if len(oid) == 0 || size == 0 { ctx.NotFound("LFSFind", nil) return } - sha := ctx.Form("sha") + sha := ctx.FormString("sha") ctx.Data["Title"] = oid ctx.Data["PageIsSettingsLFS"] = true var hash git.SHA1 diff --git a/routers/web/repo/middlewares.go b/routers/web/repo/middlewares.go index 7625fbde32..2505443504 100644 --- a/routers/web/repo/middlewares.go +++ b/routers/web/repo/middlewares.go @@ -34,7 +34,7 @@ func SetEditorconfigIfExists(ctx *context.Context) { // SetDiffViewStyle set diff style as render variable func SetDiffViewStyle(ctx *context.Context) { - queryStyle := ctx.Form("style") + queryStyle := ctx.FormString("style") if !ctx.IsSigned { ctx.Data["IsSplitStyle"] = queryStyle == "split" @@ -62,7 +62,7 @@ func SetDiffViewStyle(ctx *context.Context) { // SetWhitespaceBehavior set whitespace behavior as render variable func SetWhitespaceBehavior(ctx *context.Context) { - whitespaceBehavior := ctx.Form("whitespace") + whitespaceBehavior := ctx.FormString("whitespace") switch whitespaceBehavior { case "ignore-all", "ignore-eol", "ignore-change": ctx.Data["WhitespaceBehavior"] = whitespaceBehavior diff --git a/routers/web/repo/migrate.go b/routers/web/repo/migrate.go index 167b12e562..3d710d0448 100644 --- a/routers/web/repo/migrate.go +++ b/routers/web/repo/migrate.go @@ -39,22 +39,22 @@ func Migrate(ctx *context.Context) { setMigrationContextData(ctx, serviceType) if serviceType == 0 { - ctx.Data["Org"] = ctx.Form("org") - ctx.Data["Mirror"] = ctx.Form("mirror") + ctx.Data["Org"] = ctx.FormString("org") + ctx.Data["Mirror"] = ctx.FormString("mirror") ctx.HTML(http.StatusOK, tplMigrate) return } ctx.Data["private"] = getRepoPrivate(ctx) - ctx.Data["mirror"] = ctx.Form("mirror") == "1" - ctx.Data["lfs"] = ctx.Form("lfs") == "1" - ctx.Data["wiki"] = ctx.Form("wiki") == "1" - ctx.Data["milestones"] = ctx.Form("milestones") == "1" - ctx.Data["labels"] = ctx.Form("labels") == "1" - ctx.Data["issues"] = ctx.Form("issues") == "1" - ctx.Data["pull_requests"] = ctx.Form("pull_requests") == "1" - ctx.Data["releases"] = ctx.Form("releases") == "1" + ctx.Data["mirror"] = ctx.FormString("mirror") == "1" + ctx.Data["lfs"] = ctx.FormString("lfs") == "1" + ctx.Data["wiki"] = ctx.FormString("wiki") == "1" + ctx.Data["milestones"] = ctx.FormString("milestones") == "1" + ctx.Data["labels"] = ctx.FormString("labels") == "1" + ctx.Data["issues"] = ctx.FormString("issues") == "1" + ctx.Data["pull_requests"] = ctx.FormString("pull_requests") == "1" + ctx.Data["releases"] = ctx.FormString("releases") == "1" ctxUser := checkContextUser(ctx, ctx.FormInt64("org")) if ctx.Written() { diff --git a/routers/web/repo/milestone.go b/routers/web/repo/milestone.go index c8eda66680..675cfef0aa 100644 --- a/routers/web/repo/milestone.go +++ b/routers/web/repo/milestone.go @@ -36,7 +36,7 @@ func Milestones(ctx *context.Context) { ctx.Data["PageIsIssueList"] = true ctx.Data["PageIsMilestones"] = true - isShowClosed := ctx.Form("state") == "closed" + isShowClosed := ctx.FormString("state") == "closed" stats, err := models.GetMilestonesStatsByRepoCond(builder.And(builder.Eq{"id": ctx.Repo.Repository.ID})) if err != nil { ctx.ServerError("MilestoneStats", err) @@ -45,9 +45,9 @@ func Milestones(ctx *context.Context) { ctx.Data["OpenCount"] = stats.OpenCount ctx.Data["ClosedCount"] = stats.ClosedCount - sortType := ctx.Form("sort") + sortType := ctx.FormString("sort") - keyword := strings.Trim(ctx.Form("q"), " ") + keyword := strings.Trim(ctx.FormString("q"), " ") page := ctx.FormInt("page") if page <= 1 { diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index ccdd670e6a..2fa5ab9186 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -1129,8 +1129,8 @@ func CompareAndPullRequestPost(ctx *context.Context) { // TriggerTask response for a trigger task request func TriggerTask(ctx *context.Context) { pusherID := ctx.FormInt64("pusher") - branch := ctx.Form("branch") - secret := ctx.Form("secret") + branch := ctx.FormString("branch") + secret := ctx.FormString("secret") if len(branch) == 0 || len(secret) == 0 || pusherID <= 0 { ctx.Error(http.StatusNotFound) log.Trace("TriggerTask: branch or secret is empty, or pusher ID is not valid") diff --git a/routers/web/repo/pull_review.go b/routers/web/repo/pull_review.go index b087e40ce6..257aa737f6 100644 --- a/routers/web/repo/pull_review.go +++ b/routers/web/repo/pull_review.go @@ -101,8 +101,8 @@ func CreateCodeComment(ctx *context.Context) { // UpdateResolveConversation add or remove an Conversation resolved mark func UpdateResolveConversation(ctx *context.Context) { - origin := ctx.Form("origin") - action := ctx.Form("action") + origin := ctx.FormString("origin") + action := ctx.FormString("action") commentID := ctx.FormInt64("comment_id") comment, err := models.GetCommentByID(commentID) diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index d0e59c8fa4..d1d904bcd9 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -252,7 +252,7 @@ func NewRelease(ctx *context.Context) { ctx.Data["RequireSimpleMDE"] = true ctx.Data["RequireTribute"] = true ctx.Data["tag_target"] = ctx.Repo.Repository.DefaultBranch - if tagName := ctx.Form("tag"); len(tagName) > 0 { + if tagName := ctx.FormString("tag"); len(tagName) > 0 { rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName) if err != nil && !models.IsErrReleaseNotExist(err) { ctx.ServerError("GetRelease", err) diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index d2c1a0c399..98f60c6b59 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -291,8 +291,8 @@ func Action(ctx *context.Context) { return } - ctx.Repo.Repository.Description = ctx.Form("desc") - ctx.Repo.Repository.Website = ctx.Form("site") + ctx.Repo.Repository.Description = ctx.FormString("desc") + ctx.Repo.Repository.Website = ctx.FormString("site") err = models.UpdateRepository(ctx.Repo.Repository, false) } @@ -301,7 +301,7 @@ func Action(ctx *context.Context) { return } - ctx.RedirectToFirst(ctx.Form("redirect_to"), ctx.Repo.RepoLink) + ctx.RedirectToFirst(ctx.FormString("redirect_to"), ctx.Repo.RepoLink) } func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error { diff --git a/routers/web/repo/search.go b/routers/web/repo/search.go index 6fbc4fb4d5..02dd257cda 100644 --- a/routers/web/repo/search.go +++ b/routers/web/repo/search.go @@ -22,13 +22,13 @@ func Search(ctx *context.Context) { ctx.Redirect(ctx.Repo.RepoLink, 302) return } - language := strings.TrimSpace(ctx.Form("l")) - keyword := strings.TrimSpace(ctx.Form("q")) + language := strings.TrimSpace(ctx.FormString("l")) + keyword := strings.TrimSpace(ctx.FormString("q")) page := ctx.FormInt("page") if page <= 0 { page = 1 } - queryType := strings.TrimSpace(ctx.Form("t")) + queryType := strings.TrimSpace(ctx.FormString("t")) isMatch := queryType == "match" total, searchResults, searchResultLanguages, err := code_indexer.PerformSearch([]int64{ctx.Repo.Repository.ID}, diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go index c1c49e8ac6..2f15610737 100644 --- a/routers/web/repo/setting.go +++ b/routers/web/repo/setting.go @@ -70,7 +70,7 @@ func SettingsPost(ctx *context.Context) { repo := ctx.Repo.Repository - switch ctx.Form("action") { + switch ctx.FormString("action") { case "update": if ctx.HasError() { ctx.HTML(http.StatusOK, tplSettingsOptions) @@ -560,7 +560,7 @@ func SettingsPost(ctx *context.Context) { return } - newOwner, err := models.GetUserByName(ctx.Form("new_owner_name")) + newOwner, err := models.GetUserByName(ctx.FormString("new_owner_name")) if err != nil { if models.IsErrUserNotExist(err) { ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_owner_name"), tplSettingsOptions, nil) @@ -775,7 +775,7 @@ func Collaboration(ctx *context.Context) { // CollaborationPost response for actions for a collaboration of a repository func CollaborationPost(ctx *context.Context) { - name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Form("collaborator"))) + name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("collaborator"))) if len(name) == 0 || ctx.Repo.Owner.LowerName == name { ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path) return @@ -854,7 +854,7 @@ func AddTeamPost(ctx *context.Context) { return } - name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Form("team"))) + name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("team"))) if len(name) == 0 { ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") return @@ -988,7 +988,7 @@ func GitHooksEditPost(ctx *context.Context) { } return } - hook.Content = ctx.Form("content") + hook.Content = ctx.FormString("content") if err = hook.Update(); err != nil { ctx.ServerError("hook.Update", err) return diff --git a/routers/web/repo/setting_protected_branch.go b/routers/web/repo/setting_protected_branch.go index 7a1a3d0bcf..30c7d81b8e 100644 --- a/routers/web/repo/setting_protected_branch.go +++ b/routers/web/repo/setting_protected_branch.go @@ -60,14 +60,14 @@ func ProtectedBranchPost(ctx *context.Context) { repo := ctx.Repo.Repository - switch ctx.Form("action") { + switch ctx.FormString("action") { case "default_branch": if ctx.HasError() { ctx.HTML(http.StatusOK, tplBranches) return } - branch := ctx.Form("branch") + branch := ctx.FormString("branch") if !ctx.Repo.GitRepo.IsBranchExist(branch) { ctx.Status(404) return diff --git a/routers/web/repo/topic.go b/routers/web/repo/topic.go index 5a24d7b2b6..2a2a04c111 100644 --- a/routers/web/repo/topic.go +++ b/routers/web/repo/topic.go @@ -23,7 +23,7 @@ func TopicsPost(ctx *context.Context) { } var topics = make([]string, 0) - var topicsStr = strings.TrimSpace(ctx.Form("topics")) + var topicsStr = strings.TrimSpace(ctx.FormString("topics")) if len(topicsStr) > 0 { topics = strings.Split(topicsStr, ",") } diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index b0c8ba970a..6c8645226f 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -416,7 +416,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st isTextFile := st.IsText() isLFSFile := false - isDisplayingSource := ctx.Form("display") == "source" + isDisplayingSource := ctx.FormString("display") == "source" isDisplayingRendered := !isDisplayingSource //Check for LFS meta file |