aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-08-11 02:31:13 +0200
committerGitHub <noreply@github.com>2021-08-11 02:31:13 +0200
commitc4d70a032564f610b7215d3d3973943abbc7395f (patch)
tree2aa8fe44a1b4d0251a18ae671509d4f2439ed85d /routers/web
parent2eeae4edb685b22e926d301465d771fe7a0b0c83 (diff)
downloadgitea-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')
-rw-r--r--routers/web/admin/admin.go12
-rw-r--r--routers/web/admin/emails.go14
-rw-r--r--routers/web/admin/repos.go10
-rw-r--r--routers/web/explore/code.go6
-rw-r--r--routers/web/explore/repo.go6
-rw-r--r--routers/web/explore/user.go6
-rw-r--r--routers/web/goget.go2
-rw-r--r--routers/web/org/home.go6
-rw-r--r--routers/web/org/org_labels.go4
-rw-r--r--routers/web/org/setting.go2
-rw-r--r--routers/web/org/teams.go6
-rw-r--r--routers/web/repo/attachment.go2
-rw-r--r--routers/web/repo/branch.go4
-rw-r--r--routers/web/repo/commit.go2
-rw-r--r--routers/web/repo/compare.go6
-rw-r--r--routers/web/repo/http.go4
-rw-r--r--routers/web/repo/issue.go46
-rw-r--r--routers/web/repo/issue_label.go8
-rw-r--r--routers/web/repo/lfs.go6
-rw-r--r--routers/web/repo/middlewares.go4
-rw-r--r--routers/web/repo/migrate.go20
-rw-r--r--routers/web/repo/milestone.go6
-rw-r--r--routers/web/repo/pull.go4
-rw-r--r--routers/web/repo/pull_review.go4
-rw-r--r--routers/web/repo/release.go2
-rw-r--r--routers/web/repo/repo.go6
-rw-r--r--routers/web/repo/search.go6
-rw-r--r--routers/web/repo/setting.go10
-rw-r--r--routers/web/repo/setting_protected_branch.go4
-rw-r--r--routers/web/repo/topic.go2
-rw-r--r--routers/web/repo/view.go2
-rw-r--r--routers/web/user/auth.go26
-rw-r--r--routers/web/user/auth_openid.go4
-rw-r--r--routers/web/user/home.go30
-rw-r--r--routers/web/user/notification.go8
-rw-r--r--routers/web/user/profile.go12
-rw-r--r--routers/web/user/setting/account.go10
-rw-r--r--routers/web/user/setting/adopt.go4
-rw-r--r--routers/web/user/setting/keys.go4
-rw-r--r--routers/web/user/setting/security.go2
40 files changed, 161 insertions, 161 deletions
diff --git a/routers/web/admin/admin.go b/routers/web/admin/admin.go
index 5db4331228..ce177ea090 100644
--- a/routers/web/admin/admin.go
+++ b/routers/web/admin/admin.go
@@ -161,7 +161,7 @@ func DashboardPost(ctx *context.Context) {
// SendTestMail send test mail to confirm mail service is OK
func SendTestMail(ctx *context.Context) {
- email := ctx.Form("email")
+ email := ctx.FormString("email")
// Send a test email to the user's email address and redirect back to Config
if err := mailer.SendTestMail(email); err != nil {
ctx.Flash.Error(ctx.Tr("admin.config.test_mail_failed", email, err))
@@ -377,7 +377,7 @@ func Flush(ctx *context.Context) {
ctx.Status(404)
return
}
- timeout, err := time.ParseDuration(ctx.Form("timeout"))
+ timeout, err := time.ParseDuration(ctx.FormString("timeout"))
if err != nil {
timeout = -1
}
@@ -405,7 +405,7 @@ func AddWorkers(ctx *context.Context) {
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
return
}
- timeout, err := time.ParseDuration(ctx.Form("timeout"))
+ timeout, err := time.ParseDuration(ctx.FormString("timeout"))
if err != nil {
ctx.Flash.Error(ctx.Tr("admin.monitor.queue.pool.addworkers.musttimeoutduration"))
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
@@ -435,9 +435,9 @@ func SetQueueSettings(ctx *context.Context) {
return
}
- maxNumberStr := ctx.Form("max-number")
- numberStr := ctx.Form("number")
- timeoutStr := ctx.Form("timeout")
+ maxNumberStr := ctx.FormString("max-number")
+ numberStr := ctx.FormString("number")
+ timeoutStr := ctx.FormString("timeout")
var err error
var maxNumber, number int
diff --git a/routers/web/admin/emails.go b/routers/web/admin/emails.go
index c2fb474477..017d696e20 100644
--- a/routers/web/admin/emails.go
+++ b/routers/web/admin/emails.go
@@ -51,8 +51,8 @@ func Emails(ctx *context.Context) {
orderBy models.SearchEmailOrderBy
)
- ctx.Data["SortType"] = ctx.Form("sort")
- switch ctx.Form("sort") {
+ ctx.Data["SortType"] = ctx.FormString("sort")
+ switch ctx.FormString("sort") {
case "email":
orderBy = models.SearchEmailOrderByEmail
case "reverseemail":
@@ -68,10 +68,10 @@ func Emails(ctx *context.Context) {
opts.Keyword = ctx.FormTrim("q")
opts.SortType = orderBy
- if len(ctx.Form("is_activated")) != 0 {
+ if len(ctx.FormString("is_activated")) != 0 {
opts.IsActivated = util.OptionalBoolOf(ctx.FormBool("activated"))
}
- if len(ctx.Form("is_primary")) != 0 {
+ if len(ctx.FormString("is_primary")) != 0 {
opts.IsPrimary = util.OptionalBoolOf(ctx.FormBool("primary"))
}
@@ -114,9 +114,9 @@ func ActivateEmail(ctx *context.Context) {
truefalse := map[string]bool{"1": true, "0": false}
uid := ctx.FormInt64("uid")
- email := ctx.Form("email")
- primary, okp := truefalse[ctx.Form("primary")]
- activate, oka := truefalse[ctx.Form("activate")]
+ email := ctx.FormString("email")
+ primary, okp := truefalse[ctx.FormString("primary")]
+ activate, oka := truefalse[ctx.FormString("activate")]
if uid == 0 || len(email) == 0 || !okp || !oka {
ctx.Error(http.StatusBadRequest)
diff --git a/routers/web/admin/repos.go b/routers/web/admin/repos.go
index 34b7af2690..15d4554957 100644
--- a/routers/web/admin/repos.go
+++ b/routers/web/admin/repos.go
@@ -59,7 +59,7 @@ func DeleteRepo(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success"))
ctx.JSON(http.StatusOK, map[string]interface{}{
- "redirect": setting.AppSubURL + "/admin/repos?page=" + ctx.Form("page") + "&sort=" + ctx.Form("sort"),
+ "redirect": setting.AppSubURL + "/admin/repos?page=" + ctx.FormString("page") + "&sort=" + ctx.FormString("sort"),
})
}
@@ -83,7 +83,7 @@ func UnadoptedRepos(ctx *context.Context) {
doSearch := ctx.FormBool("search")
ctx.Data["search"] = doSearch
- q := ctx.Form("q")
+ q := ctx.FormString("q")
if !doSearch {
pager := context.NewPagination(0, opts.PageSize, opts.Page, 5)
@@ -109,10 +109,10 @@ func UnadoptedRepos(ctx *context.Context) {
// AdoptOrDeleteRepository adopts or deletes a repository
func AdoptOrDeleteRepository(ctx *context.Context) {
- dir := ctx.Form("id")
- action := ctx.Form("action")
+ dir := ctx.FormString("id")
+ action := ctx.FormString("action")
page := ctx.FormInt("page")
- q := ctx.Form("q")
+ q := ctx.FormString("q")
dirSplit := strings.SplitN(dir, "/", 2)
if len(dirSplit) != 2 {
diff --git a/routers/web/explore/code.go b/routers/web/explore/code.go
index 5dd8298b2d..55a4409145 100644
--- a/routers/web/explore/code.go
+++ b/routers/web/explore/code.go
@@ -33,14 +33,14 @@ func Code(ctx *context.Context) {
ctx.Data["PageIsExplore"] = true
ctx.Data["PageIsExploreCode"] = true
- 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"
var (
diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go
index faac639caa..83fb721a7d 100644
--- a/routers/web/explore/repo.go
+++ b/routers/web/explore/repo.go
@@ -42,8 +42,8 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
orderBy models.SearchOrderBy
)
- ctx.Data["SortType"] = ctx.Form("sort")
- switch ctx.Form("sort") {
+ ctx.Data["SortType"] = ctx.FormString("sort")
+ switch ctx.FormString("sort") {
case "newest":
orderBy = models.SearchOrderByNewest
case "oldest":
@@ -73,7 +73,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
orderBy = models.SearchOrderByRecentUpdated
}
- keyword := strings.Trim(ctx.Form("q"), " ")
+ keyword := strings.Trim(ctx.FormString("q"), " ")
topicOnly := ctx.FormBool("topic")
ctx.Data["TopicOnly"] = topicOnly
diff --git a/routers/web/explore/user.go b/routers/web/explore/user.go
index 85c45c7eff..06dcdb3c6a 100644
--- a/routers/web/explore/user.go
+++ b/routers/web/explore/user.go
@@ -44,8 +44,8 @@ func RenderUserSearch(ctx *context.Context, opts *models.SearchUserOptions, tplN
orderBy models.SearchOrderBy
)
- ctx.Data["SortType"] = ctx.Form("sort")
- switch ctx.Form("sort") {
+ ctx.Data["SortType"] = ctx.FormString("sort")
+ switch ctx.FormString("sort") {
case "newest":
orderBy = models.SearchOrderByIDReverse
case "oldest":
@@ -63,7 +63,7 @@ func RenderUserSearch(ctx *context.Context, opts *models.SearchUserOptions, tplN
orderBy = models.SearchOrderByAlphabetically
}
- opts.Keyword = strings.Trim(ctx.Form("q"), " ")
+ opts.Keyword = strings.Trim(ctx.FormString("q"), " ")
opts.OrderBy = orderBy
if len(opts.Keyword) == 0 || isKeywordValid(opts.Keyword) {
users, count, err = models.SearchUsers(opts)
diff --git a/routers/web/goget.go b/routers/web/goget.go
index 1680153b49..02adf9c5ea 100644
--- a/routers/web/goget.go
+++ b/routers/web/goget.go
@@ -18,7 +18,7 @@ import (
)
func goGet(ctx *context.Context) {
- if ctx.Req.Method != "GET" || ctx.Form("go-get") != "1" || len(ctx.Req.URL.Query()) > 1 {
+ if ctx.Req.Method != "GET" || ctx.FormString("go-get") != "1" || len(ctx.Req.URL.Query()) > 1 {
return
}
diff --git a/routers/web/org/home.go b/routers/web/org/home.go
index 8c1475d469..de131d27b6 100644
--- a/routers/web/org/home.go
+++ b/routers/web/org/home.go
@@ -51,8 +51,8 @@ func Home(ctx *context.Context) {
}
var orderBy models.SearchOrderBy
- ctx.Data["SortType"] = ctx.Form("sort")
- switch ctx.Form("sort") {
+ ctx.Data["SortType"] = ctx.FormString("sort")
+ switch ctx.FormString("sort") {
case "newest":
orderBy = models.SearchOrderByNewest
case "oldest":
@@ -78,7 +78,7 @@ func Home(ctx *context.Context) {
orderBy = models.SearchOrderByRecentUpdated
}
- keyword := strings.Trim(ctx.Form("q"), " ")
+ keyword := strings.Trim(ctx.FormString("q"), " ")
ctx.Data["Keyword"] = keyword
page := ctx.FormInt("page")
diff --git a/routers/web/org/org_labels.go b/routers/web/org/org_labels.go
index 08457d4f8e..97a5437c61 100644
--- a/routers/web/org/org_labels.go
+++ b/routers/web/org/org_labels.go
@@ -15,7 +15,7 @@ import (
// RetrieveLabels find all the labels of an organization
func RetrieveLabels(ctx *context.Context) {
- labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.Form("sort"), models.ListOptions{})
+ labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.FormString("sort"), models.ListOptions{})
if err != nil {
ctx.ServerError("RetrieveLabels.GetLabels", err)
return
@@ -25,7 +25,7 @@ func RetrieveLabels(ctx *context.Context) {
}
ctx.Data["Labels"] = labels
ctx.Data["NumLabels"] = len(labels)
- ctx.Data["SortType"] = ctx.Form("sort")
+ ctx.Data["SortType"] = ctx.FormString("sort")
}
// NewLabel create new label for organization
diff --git a/routers/web/org/setting.go b/routers/web/org/setting.go
index 47a80ec50f..b21b94d64d 100644
--- a/routers/web/org/setting.go
+++ b/routers/web/org/setting.go
@@ -155,7 +155,7 @@ func SettingsDelete(ctx *context.Context) {
org := ctx.Org.Organization
if ctx.Req.Method == "POST" {
- if org.Name != ctx.Form("org_name") {
+ if org.Name != ctx.FormString("org_name") {
ctx.Data["Err_OrgName"] = true
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_org_name"), tplSettingsDelete, nil)
return
diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go
index a61315e05c..4725f19b3d 100644
--- a/routers/web/org/teams.go
+++ b/routers/web/org/teams.go
@@ -55,7 +55,7 @@ func TeamsAction(ctx *context.Context) {
return
}
- page := ctx.Form("page")
+ page := ctx.FormString("page")
var err error
switch ctx.Params(":action") {
case "join":
@@ -78,7 +78,7 @@ func TeamsAction(ctx *context.Context) {
ctx.Error(http.StatusNotFound)
return
}
- uname := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Form("uname")))
+ uname := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("uname")))
var u *models.User
u, err = models.GetUserByName(uname)
if err != nil {
@@ -140,7 +140,7 @@ func TeamsRepoAction(ctx *context.Context) {
action := ctx.Params(":action")
switch action {
case "add":
- repoName := path.Base(ctx.Form("repo_name"))
+ repoName := path.Base(ctx.FormString("repo_name"))
var repo *models.Repository
repo, err = models.GetRepositoryByName(ctx.Org.Organization.ID, repoName)
if err != nil {
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
diff --git a/routers/web/user/auth.go b/routers/web/user/auth.go
index 72e990f661..a9e60bb07c 100644
--- a/routers/web/user/auth.go
+++ b/routers/web/user/auth.go
@@ -111,7 +111,7 @@ func checkAutoLogin(ctx *context.Context) bool {
return true
}
- redirectTo := ctx.Form("redirect_to")
+ redirectTo := ctx.FormString("redirect_to")
if len(redirectTo) > 0 {
middleware.SetRedirectToCookie(ctx.Resp, redirectTo)
} else {
@@ -1333,7 +1333,7 @@ func handleUserCreated(ctx *context.Context, u *models.User, gothUser *goth.User
// Activate render activate user page
func Activate(ctx *context.Context) {
- code := ctx.Form("code")
+ code := ctx.FormString("code")
if len(code) == 0 {
ctx.Data["IsActivatePage"] = true
@@ -1381,7 +1381,7 @@ func Activate(ctx *context.Context) {
// ActivatePost handles account activation with password check
func ActivatePost(ctx *context.Context) {
- code := ctx.Form("code")
+ code := ctx.FormString("code")
if len(code) == 0 {
ctx.Redirect(setting.AppSubURL + "/user/activate")
return
@@ -1397,7 +1397,7 @@ func ActivatePost(ctx *context.Context) {
// if account is local account, verify password
if user.LoginSource == 0 {
- password := ctx.Form("password")
+ password := ctx.FormString("password")
if len(password) == 0 {
ctx.Data["Code"] = code
ctx.Data["NeedsPassword"] = true
@@ -1454,8 +1454,8 @@ func handleAccountActivation(ctx *context.Context, user *models.User) {
// ActivateEmail render the activate email page
func ActivateEmail(ctx *context.Context) {
- code := ctx.Form("code")
- emailStr := ctx.Form("email")
+ code := ctx.FormString("code")
+ emailStr := ctx.FormString("email")
// Verify code.
if email := models.VerifyActiveEmailCode(code, emailStr); email != nil {
@@ -1491,7 +1491,7 @@ func ForgotPasswd(ctx *context.Context) {
return
}
- email := ctx.Form("email")
+ email := ctx.FormString("email")
ctx.Data["Email"] = email
ctx.Data["IsResetRequest"] = true
@@ -1508,7 +1508,7 @@ func ForgotPasswdPost(ctx *context.Context) {
}
ctx.Data["IsResetRequest"] = true
- email := ctx.Form("email")
+ email := ctx.FormString("email")
ctx.Data["Email"] = email
u, err := models.GetUserByEmail(email)
@@ -1548,7 +1548,7 @@ func ForgotPasswdPost(ctx *context.Context) {
}
func commonResetPassword(ctx *context.Context) (*models.User, *models.TwoFactor) {
- code := ctx.Form("code")
+ code := ctx.FormString("code")
ctx.Data["Title"] = ctx.Tr("auth.reset_password")
ctx.Data["Code"] = code
@@ -1617,7 +1617,7 @@ func ResetPasswdPost(ctx *context.Context) {
}
// Validate password length.
- passwd := ctx.Form("password")
+ passwd := ctx.FormString("password")
if len(passwd) < setting.MinPasswordLength {
ctx.Data["IsResetForm"] = true
ctx.Data["Err_Password"] = true
@@ -1644,7 +1644,7 @@ func ResetPasswdPost(ctx *context.Context) {
regenerateScratchToken := false
if twofa != nil {
if ctx.FormBool("scratch_code") {
- if !twofa.VerifyScratchToken(ctx.Form("token")) {
+ if !twofa.VerifyScratchToken(ctx.FormString("token")) {
ctx.Data["IsResetForm"] = true
ctx.Data["Err_Token"] = true
ctx.RenderWithErr(ctx.Tr("auth.twofa_scratch_token_incorrect"), tplResetPassword, nil)
@@ -1652,7 +1652,7 @@ func ResetPasswdPost(ctx *context.Context) {
}
regenerateScratchToken = true
} else {
- passcode := ctx.Form("passcode")
+ passcode := ctx.FormString("passcode")
ok, err := twofa.ValidateTOTP(passcode)
if err != nil {
ctx.Error(http.StatusInternalServerError, "ValidateTOTP", err.Error())
@@ -1689,7 +1689,7 @@ func ResetPasswdPost(ctx *context.Context) {
log.Trace("User password reset: %s", u.Name)
ctx.Data["IsResetFailed"] = true
- remember := len(ctx.Form("remember")) != 0
+ remember := len(ctx.FormString("remember")) != 0
if regenerateScratchToken {
// Invalidate the scratch token.
diff --git a/routers/web/user/auth_openid.go b/routers/web/user/auth_openid.go
index 9106f012ff..fc419a7f6e 100644
--- a/routers/web/user/auth_openid.go
+++ b/routers/web/user/auth_openid.go
@@ -34,7 +34,7 @@ const (
func SignInOpenID(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("sign_in")
- if ctx.Form("openid.return_to") != "" {
+ if ctx.FormString("openid.return_to") != "" {
signInOpenIDVerify(ctx)
return
}
@@ -46,7 +46,7 @@ func SignInOpenID(ctx *context.Context) {
return
}
- redirectTo := ctx.Form("redirect_to")
+ redirectTo := ctx.FormString("redirect_to")
if len(redirectTo) > 0 {
middleware.SetRedirectToCookie(ctx.Resp, redirectTo)
} else {
diff --git a/routers/web/user/home.go b/routers/web/user/home.go
index 3b89840720..285f1ff367 100644
--- a/routers/web/user/home.go
+++ b/routers/web/user/home.go
@@ -157,7 +157,7 @@ func Dashboard(ctx *context.Context) {
IncludePrivate: true,
OnlyPerformedBy: false,
IncludeDeleted: false,
- Date: ctx.Form("date"),
+ Date: ctx.FormString("date"),
})
if ctx.Written() {
@@ -200,11 +200,11 @@ func Milestones(ctx *context.Context) {
repoCond = userRepoCond
repoIDs []int64
- reposQuery = ctx.Form("repos")
- isShowClosed = ctx.Form("state") == "closed"
- sortType = ctx.Form("sort")
+ reposQuery = ctx.FormString("repos")
+ isShowClosed = ctx.FormString("state") == "closed"
+ sortType = ctx.FormString("sort")
page = ctx.FormInt("page")
- keyword = strings.Trim(ctx.Form("q"), " ")
+ keyword = strings.Trim(ctx.FormString("q"), " ")
)
if page <= 1 {
@@ -380,7 +380,7 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
var (
viewType string
- sortType = ctx.Form("sort")
+ sortType = ctx.FormString("sort")
filterMode = models.FilterModeAll
)
@@ -390,14 +390,14 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
// - Remember pre-determined viewType string for later. Will be posted to ctx.Data.
// Organization does not have view type and filter mode.
// User:
- // - Use ctx.Form("type") to determine filterMode.
+ // - Use ctx.FormString("type") to determine filterMode.
// The type is set when clicking for example "assigned to me" on the overview page.
// - Remember either this or a fallback. Will be posted to ctx.Data.
// --------------------------------------------------------------------------------
// TODO: distinguish during routing
- viewType = ctx.Form("type")
+ viewType = ctx.FormString("type")
switch viewType {
case "assigned":
filterMode = models.FilterModeAssign
@@ -456,7 +456,7 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
}
// keyword holds the search term entered into the search field.
- keyword := strings.Trim(ctx.Form("q"), " ")
+ keyword := strings.Trim(ctx.FormString("q"), " ")
ctx.Data["Keyword"] = keyword
// Execute keyword search for issues.
@@ -477,7 +477,7 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
}
// Educated guess: Do or don't show closed issues.
- isShowClosed := ctx.Form("state") == "closed"
+ isShowClosed := ctx.FormString("state") == "closed"
opts.IsClosed = util.OptionalBoolOf(isShowClosed)
// Filter repos and count issues in them. Count will be used later.
@@ -502,7 +502,7 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
// Get IDs for labels (a filter option for issues/pulls).
// Required for IssuesOptions.
var labelIDs []int64
- selectedLabels := ctx.Form("labels")
+ selectedLabels := ctx.FormString("labels")
if len(selectedLabels) > 0 && selectedLabels != "0" {
labelIDs, err = base.StringsToInt64s(strings.Split(selectedLabels, ","))
if err != nil {
@@ -512,9 +512,9 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
}
opts.LabelIDs = labelIDs
- // Parse ctx.Form("repos") and remember matched repo IDs for later.
+ // Parse ctx.FormString("repos") and remember matched repo IDs for later.
// Gets set when clicking filters on the issues overview page.
- repoIDs := getRepoIDs(ctx.Form("repos"))
+ repoIDs := getRepoIDs(ctx.FormString("repos"))
if len(repoIDs) > 0 {
opts.RepoIDs = repoIDs
}
@@ -658,7 +658,7 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
ctx.Data["IsShowClosed"] = isShowClosed
ctx.Data["IssueRefEndNames"], ctx.Data["IssueRefURLs"] =
- issue_service.GetRefEndNamesAndURLs(issues, ctx.Form("RepoLink"))
+ issue_service.GetRefEndNamesAndURLs(issues, ctx.FormString("RepoLink"))
ctx.Data["Issues"] = issues
@@ -900,7 +900,7 @@ func ShowGPGKeys(ctx *context.Context, uid int64) {
// Email2User show user page via email
func Email2User(ctx *context.Context) {
- u, err := models.GetUserByEmail(ctx.Form("email"))
+ u, err := models.GetUserByEmail(ctx.FormString("email"))
if err != nil {
if models.IsErrUserNotExist(err) {
ctx.NotFound("GetUserByEmail", err)
diff --git a/routers/web/user/notification.go b/routers/web/user/notification.go
index 0a43cbbf27..bc017db9d4 100644
--- a/routers/web/user/notification.go
+++ b/routers/web/user/notification.go
@@ -50,7 +50,7 @@ func Notifications(c *context.Context) {
return
}
if c.FormBool("div-only") {
- c.Data["SequenceNumber"] = c.Form("sequence-number")
+ c.Data["SequenceNumber"] = c.FormString("sequence-number")
c.HTML(http.StatusOK, tplNotificationDiv)
return
}
@@ -59,7 +59,7 @@ func Notifications(c *context.Context) {
func getNotifications(c *context.Context) {
var (
- keyword = strings.Trim(c.Form("q"), " ")
+ keyword = strings.Trim(c.FormString("q"), " ")
status models.NotificationStatus
page = c.FormInt("page")
perPage = c.FormInt("perPage")
@@ -87,7 +87,7 @@ func getNotifications(c *context.Context) {
// redirect to last page if request page is more than total pages
pager := context.NewPagination(int(total), perPage, page, 5)
if pager.Paginater.Current() < page {
- c.Redirect(fmt.Sprintf("/notifications?q=%s&page=%d", c.Form("q"), pager.Paginater.Current()))
+ c.Redirect(fmt.Sprintf("/notifications?q=%s&page=%d", c.FormString("q"), pager.Paginater.Current()))
return
}
@@ -167,7 +167,7 @@ func NotificationStatusPost(c *context.Context) {
}
if !c.FormBool("noredirect") {
- url := fmt.Sprintf("%s/notifications?page=%s", setting.AppSubURL, c.Form("page"))
+ url := fmt.Sprintf("%s/notifications?page=%s", setting.AppSubURL, c.FormString("page"))
c.Redirect(url, http.StatusSeeOther)
}
diff --git a/routers/web/user/profile.go b/routers/web/user/profile.go
index cb14347886..e6a8e5b5a8 100644
--- a/routers/web/user/profile.go
+++ b/routers/web/user/profile.go
@@ -143,7 +143,7 @@ func Profile(ctx *context.Context) {
ctx.Data["Orgs"] = orgs
ctx.Data["HasOrgsVisible"] = models.HasOrgsVisible(orgs, ctx.User)
- tab := ctx.Form("tab")
+ tab := ctx.FormString("tab")
ctx.Data["TabName"] = tab
page := ctx.FormInt("page")
@@ -160,8 +160,8 @@ func Profile(ctx *context.Context) {
orderBy models.SearchOrderBy
)
- ctx.Data["SortType"] = ctx.Form("sort")
- switch ctx.Form("sort") {
+ ctx.Data["SortType"] = ctx.FormString("sort")
+ switch ctx.FormString("sort") {
case "newest":
orderBy = models.SearchOrderByNewest
case "oldest":
@@ -187,7 +187,7 @@ func Profile(ctx *context.Context) {
orderBy = models.SearchOrderByRecentUpdated
}
- keyword := strings.Trim(ctx.Form("q"), " ")
+ keyword := strings.Trim(ctx.FormString("q"), " ")
ctx.Data["Keyword"] = keyword
switch tab {
case "followers":
@@ -220,7 +220,7 @@ func Profile(ctx *context.Context) {
IncludePrivate: showPrivate,
OnlyPerformedBy: true,
IncludeDeleted: false,
- Date: ctx.Form("date"),
+ Date: ctx.FormString("date"),
})
if ctx.Written() {
return
@@ -332,5 +332,5 @@ func Action(ctx *context.Context) {
return
}
- ctx.RedirectToFirst(ctx.Form("redirect_to"), u.HomeLink())
+ ctx.RedirectToFirst(ctx.FormString("redirect_to"), u.HomeLink())
}
diff --git a/routers/web/user/setting/account.go b/routers/web/user/setting/account.go
index ea349949f9..6201078954 100644
--- a/routers/web/user/setting/account.go
+++ b/routers/web/user/setting/account.go
@@ -90,7 +90,7 @@ func EmailPost(ctx *context.Context) {
ctx.Data["PageIsSettingsAccount"] = true
// Make emailaddress primary.
- if ctx.Form("_method") == "PRIMARY" {
+ if ctx.FormString("_method") == "PRIMARY" {
if err := models.MakeEmailPrimary(&models.EmailAddress{ID: ctx.FormInt64("id")}); err != nil {
ctx.ServerError("MakeEmailPrimary", err)
return
@@ -101,7 +101,7 @@ func EmailPost(ctx *context.Context) {
return
}
// Send activation Email
- if ctx.Form("_method") == "SENDACTIVATION" {
+ if ctx.FormString("_method") == "SENDACTIVATION" {
var address string
if ctx.Cache.IsExist("MailResendLimit_" + ctx.User.LowerName) {
log.Error("Send activation: activation still pending")
@@ -147,8 +147,8 @@ func EmailPost(ctx *context.Context) {
return
}
// Set Email Notification Preference
- if ctx.Form("_method") == "NOTIFICATION" {
- preference := ctx.Form("preference")
+ if ctx.FormString("_method") == "NOTIFICATION" {
+ preference := ctx.FormString("preference")
if !(preference == models.EmailNotificationsEnabled ||
preference == models.EmailNotificationsOnMention ||
preference == models.EmailNotificationsDisabled) {
@@ -229,7 +229,7 @@ func DeleteAccount(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsAccount"] = true
- if _, err := auth.UserSignIn(ctx.User.Name, ctx.Form("password")); err != nil {
+ if _, err := auth.UserSignIn(ctx.User.Name, ctx.FormString("password")); err != nil {
if models.IsErrUserNotExist(err) {
loadAccountData(ctx)
diff --git a/routers/web/user/setting/adopt.go b/routers/web/user/setting/adopt.go
index 8ade9c4257..e45a8a1324 100644
--- a/routers/web/user/setting/adopt.go
+++ b/routers/web/user/setting/adopt.go
@@ -23,8 +23,8 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
allowDelete := ctx.IsUserSiteAdmin() || setting.Repository.AllowDeleteOfUnadoptedRepositories
ctx.Data["allowDelete"] = allowDelete
- dir := ctx.Form("id")
- action := ctx.Form("action")
+ dir := ctx.FormString("id")
+ action := ctx.FormString("action")
ctxUser := ctx.User
root := filepath.Join(models.UserPath(ctxUser.LowerName))
diff --git a/routers/web/user/setting/keys.go b/routers/web/user/setting/keys.go
index c1ea87cabc..24b9a9e205 100644
--- a/routers/web/user/setting/keys.go
+++ b/routers/web/user/setting/keys.go
@@ -193,7 +193,7 @@ func KeysPost(ctx *context.Context) {
// DeleteKey response for delete user's SSH/GPG key
func DeleteKey(ctx *context.Context) {
- switch ctx.Form("type") {
+ switch ctx.FormString("type") {
case "gpg":
if err := models.DeleteGPGKey(ctx.User, ctx.FormInt64("id")); err != nil {
ctx.Flash.Error("DeleteGPGKey: " + err.Error())
@@ -265,5 +265,5 @@ func loadKeysData(ctx *context.Context) {
}
ctx.Data["Principals"] = principals
- ctx.Data["VerifyingID"] = ctx.Form("verify_gpg")
+ ctx.Data["VerifyingID"] = ctx.FormString("verify_gpg")
}
diff --git a/routers/web/user/setting/security.go b/routers/web/user/setting/security.go
index 36c6d7df72..3406194015 100644
--- a/routers/web/user/setting/security.go
+++ b/routers/web/user/setting/security.go
@@ -25,7 +25,7 @@ func Security(ctx *context.Context) {
ctx.Data["PageIsSettingsSecurity"] = true
ctx.Data["RequireU2F"] = true
- if ctx.Form("openid.return_to") != "" {
+ if ctx.FormString("openid.return_to") != "" {
settingsOpenIDVerify(ctx)
return
}