]> source.dussan.org Git - gitea.git/commitdiff
Rename ctx.Form() to ctx.FormString() and move code into own file (#16571)
author6543 <6543@obermui.de>
Wed, 11 Aug 2021 00:31:13 +0000 (02:31 +0200)
committerGitHub <noreply@github.com>
Wed, 11 Aug 2021 00:31:13 +0000 (02:31 +0200)
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

64 files changed:
modules/context/context.go
modules/context/form.go
modules/context/repo.go
routers/api/v1/admin/adopt.go
routers/api/v1/api.go
routers/api/v1/notify/repo.go
routers/api/v1/notify/threads.go
routers/api/v1/notify/user.go
routers/api/v1/org/label.go
routers/api/v1/org/team.go
routers/api/v1/repo/commits.go
routers/api/v1/repo/issue.go
routers/api/v1/repo/issue_tracked_time.go
routers/api/v1/repo/key.go
routers/api/v1/repo/label.go
routers/api/v1/repo/milestone.go
routers/api/v1/repo/release_attachment.go
routers/api/v1/repo/repo.go
routers/api/v1/repo/topic.go
routers/api/v1/user/key.go
routers/api/v1/user/user.go
routers/api/v1/utils/utils.go
routers/private/key.go
routers/web/admin/admin.go
routers/web/admin/emails.go
routers/web/admin/repos.go
routers/web/explore/code.go
routers/web/explore/repo.go
routers/web/explore/user.go
routers/web/goget.go
routers/web/org/home.go
routers/web/org/org_labels.go
routers/web/org/setting.go
routers/web/org/teams.go
routers/web/repo/attachment.go
routers/web/repo/branch.go
routers/web/repo/commit.go
routers/web/repo/compare.go
routers/web/repo/http.go
routers/web/repo/issue.go
routers/web/repo/issue_label.go
routers/web/repo/lfs.go
routers/web/repo/middlewares.go
routers/web/repo/migrate.go
routers/web/repo/milestone.go
routers/web/repo/pull.go
routers/web/repo/pull_review.go
routers/web/repo/release.go
routers/web/repo/repo.go
routers/web/repo/search.go
routers/web/repo/setting.go
routers/web/repo/setting_protected_branch.go
routers/web/repo/topic.go
routers/web/repo/view.go
routers/web/user/auth.go
routers/web/user/auth_openid.go
routers/web/user/home.go
routers/web/user/notification.go
routers/web/user/profile.go
routers/web/user/setting/account.go
routers/web/user/setting/adopt.go
routers/web/user/setting/keys.go
routers/web/user/setting/security.go
services/lfs/locks.go

index 041b81c66851d1fd20000cfc28d2d26701ff6173..3dbc2bb9dcd0fc631178e6063122fb84d2777e5e 100644 (file)
@@ -28,7 +28,6 @@ import (
        "code.gitea.io/gitea/modules/setting"
        "code.gitea.io/gitea/modules/templates"
        "code.gitea.io/gitea/modules/translation"
-       "code.gitea.io/gitea/modules/util"
        "code.gitea.io/gitea/modules/web/middleware"
        "code.gitea.io/gitea/services/auth"
 
@@ -287,41 +286,6 @@ func (ctx *Context) Header() http.Header {
        return ctx.Resp.Header()
 }
 
-// Form returns request form as string with default
-func (ctx *Context) Form(key string, defaults ...string) string {
-       return (*Forms)(ctx.Req).MustString(key, defaults...)
-}
-
-// FormTrim returns request form as string with default and trimmed spaces
-func (ctx *Context) FormTrim(key string, defaults ...string) string {
-       return (*Forms)(ctx.Req).MustTrimmed(key, defaults...)
-}
-
-// FormStrings returns request form as strings with default
-func (ctx *Context) FormStrings(key string, defaults ...[]string) []string {
-       return (*Forms)(ctx.Req).MustStrings(key, defaults...)
-}
-
-// FormInt returns request form as int with default
-func (ctx *Context) FormInt(key string, defaults ...int) int {
-       return (*Forms)(ctx.Req).MustInt(key, defaults...)
-}
-
-// FormInt64 returns request form as int64 with default
-func (ctx *Context) FormInt64(key string, defaults ...int64) int64 {
-       return (*Forms)(ctx.Req).MustInt64(key, defaults...)
-}
-
-// FormBool returns request form as bool with default
-func (ctx *Context) FormBool(key string, defaults ...bool) bool {
-       return (*Forms)(ctx.Req).MustBool(key, defaults...)
-}
-
-// FormOptionalBool returns request form as OptionalBool with default
-func (ctx *Context) FormOptionalBool(key string, defaults ...util.OptionalBool) util.OptionalBool {
-       return (*Forms)(ctx.Req).MustOptionalBool(key, defaults...)
-}
-
 // HandleText handles HTTP status code
 func (ctx *Context) HandleText(status int, title string) {
        if (status/100 == 4) || (status/100 == 5) {
index e3afad0a9046ecd38e2c830989b39e984e87df35..8d185909737c7ba8e6578ebdb85d479ec6601935 100644 (file)
 package context
 
 import (
-       "errors"
-       "net/http"
-       "net/url"
        "strconv"
        "strings"
-       "text/template"
 
-       "code.gitea.io/gitea/modules/log"
        "code.gitea.io/gitea/modules/util"
 )
 
-// Forms a new enhancement of http.Request
-type Forms http.Request
-
-// Values returns http.Request values
-func (f *Forms) Values() url.Values {
-       return (*http.Request)(f).Form
-}
-
-// String returns request form as string
-func (f *Forms) String(key string) (string, error) {
-       return (*http.Request)(f).FormValue(key), nil
-}
-
-// Trimmed returns request form as string with trimed spaces left and right
-func (f *Forms) Trimmed(key string) (string, error) {
-       return strings.TrimSpace((*http.Request)(f).FormValue(key)), nil
+// FormString returns the first value matching the provided key in the form as a string
+func (ctx *Context) FormString(key string) string {
+       return ctx.Req.FormValue(key)
 }
 
-// Strings returns request form as strings
-func (f *Forms) Strings(key string) ([]string, error) {
-       if (*http.Request)(f).Form == nil {
-               if err := (*http.Request)(f).ParseMultipartForm(32 << 20); err != nil {
-                       return nil, err
+// FormStrings returns a string slice for the provided key from the form
+func (ctx *Context) FormStrings(key string) []string {
+       if ctx.Req.Form == nil {
+               if err := ctx.Req.ParseMultipartForm(32 << 20); err != nil {
+                       return nil
                }
        }
-       if v, ok := (*http.Request)(f).Form[key]; ok {
-               return v, nil
-       }
-       return nil, errors.New("not exist")
-}
-
-// Escape returns request form as escaped string
-func (f *Forms) Escape(key string) (string, error) {
-       return template.HTMLEscapeString((*http.Request)(f).FormValue(key)), nil
-}
-
-// Int returns request form as int
-func (f *Forms) Int(key string) (int, error) {
-       return strconv.Atoi((*http.Request)(f).FormValue(key))
-}
-
-// Int32 returns request form as int32
-func (f *Forms) Int32(key string) (int32, error) {
-       v, err := strconv.ParseInt((*http.Request)(f).FormValue(key), 10, 32)
-       return int32(v), err
-}
-
-// Int64 returns request form as int64
-func (f *Forms) Int64(key string) (int64, error) {
-       return strconv.ParseInt((*http.Request)(f).FormValue(key), 10, 64)
-}
-
-// Uint returns request form as uint
-func (f *Forms) Uint(key string) (uint, error) {
-       v, err := strconv.ParseUint((*http.Request)(f).FormValue(key), 10, 64)
-       return uint(v), err
-}
-
-// Uint32 returns request form as uint32
-func (f *Forms) Uint32(key string) (uint32, error) {
-       v, err := strconv.ParseUint((*http.Request)(f).FormValue(key), 10, 32)
-       return uint32(v), err
-}
-
-// Uint64 returns request form as uint64
-func (f *Forms) Uint64(key string) (uint64, error) {
-       return strconv.ParseUint((*http.Request)(f).FormValue(key), 10, 64)
-}
-
-// Bool returns request form as bool
-func (f *Forms) Bool(key string) (bool, error) {
-       return strconv.ParseBool((*http.Request)(f).FormValue(key))
-}
-
-// Float32 returns request form as float32
-func (f *Forms) Float32(key string) (float32, error) {
-       v, err := strconv.ParseFloat((*http.Request)(f).FormValue(key), 64)
-       return float32(v), err
-}
-
-// Float64 returns request form as float64
-func (f *Forms) Float64(key string) (float64, error) {
-       return strconv.ParseFloat((*http.Request)(f).FormValue(key), 64)
-}
-
-// MustString returns request form as string with default
-func (f *Forms) MustString(key string, defaults ...string) string {
-       if v := (*http.Request)(f).FormValue(key); len(v) > 0 {
+       if v, ok := ctx.Req.Form[key]; ok {
                return v
        }
-       if len(defaults) > 0 {
-               return defaults[0]
-       }
-       return ""
+       return nil
 }
 
-// MustTrimmed returns request form as string with default
-func (f *Forms) MustTrimmed(key string, defaults ...string) string {
-       return strings.TrimSpace(f.MustString(key, defaults...))
+// FormTrim returns the first value for the provided key in the form as a space trimmed string
+func (ctx *Context) FormTrim(key string) string {
+       return strings.TrimSpace(ctx.Req.FormValue(key))
 }
 
-// MustStrings returns request form as strings with default
-func (f *Forms) MustStrings(key string, defaults ...[]string) []string {
-       if (*http.Request)(f).Form == nil {
-               if err := (*http.Request)(f).ParseMultipartForm(32 << 20); err != nil {
-                       log.Error("ParseMultipartForm: %v", err)
-                       return []string{}
-               }
-       }
-
-       if v, ok := (*http.Request)(f).Form[key]; ok {
-               return v
-       }
-       if len(defaults) > 0 {
-               return defaults[0]
-       }
-       return []string{}
-}
-
-// MustEscape returns request form as escaped string with default
-func (f *Forms) MustEscape(key string, defaults ...string) string {
-       if v := (*http.Request)(f).FormValue(key); len(v) > 0 {
-               return template.HTMLEscapeString(v)
-       }
-       if len(defaults) > 0 {
-               return defaults[0]
-       }
-       return ""
-}
-
-// MustInt returns request form as int with default
-func (f *Forms) MustInt(key string, defaults ...int) int {
-       v, err := strconv.Atoi((*http.Request)(f).FormValue(key))
-       if len(defaults) > 0 && err != nil {
-               return defaults[0]
-       }
-       return v
-}
-
-// MustInt32 returns request form as int32 with default
-func (f *Forms) MustInt32(key string, defaults ...int32) int32 {
-       v, err := strconv.ParseInt((*http.Request)(f).FormValue(key), 10, 32)
-       if len(defaults) > 0 && err != nil {
-               return defaults[0]
-       }
-       return int32(v)
-}
-
-// MustInt64 returns request form as int64 with default
-func (f *Forms) MustInt64(key string, defaults ...int64) int64 {
-       v, err := strconv.ParseInt((*http.Request)(f).FormValue(key), 10, 64)
-       if len(defaults) > 0 && err != nil {
-               return defaults[0]
-       }
+// FormInt returns the first value for the provided key in the form as an int
+func (ctx *Context) FormInt(key string) int {
+       v, _ := strconv.Atoi(ctx.Req.FormValue(key))
        return v
 }
 
-// MustUint returns request form as uint with default
-func (f *Forms) MustUint(key string, defaults ...uint) uint {
-       v, err := strconv.ParseUint((*http.Request)(f).FormValue(key), 10, 64)
-       if len(defaults) > 0 && err != nil {
-               return defaults[0]
-       }
-       return uint(v)
-}
-
-// MustUint32 returns request form as uint32 with default
-func (f *Forms) MustUint32(key string, defaults ...uint32) uint32 {
-       v, err := strconv.ParseUint((*http.Request)(f).FormValue(key), 10, 32)
-       if len(defaults) > 0 && err != nil {
-               return defaults[0]
-       }
-       return uint32(v)
-}
-
-// MustUint64 returns request form as uint64 with default
-func (f *Forms) MustUint64(key string, defaults ...uint64) uint64 {
-       v, err := strconv.ParseUint((*http.Request)(f).FormValue(key), 10, 64)
-       if len(defaults) > 0 && err != nil {
-               return defaults[0]
-       }
-       return v
-}
-
-// MustFloat32 returns request form as float32 with default
-func (f *Forms) MustFloat32(key string, defaults ...float32) float32 {
-       v, err := strconv.ParseFloat((*http.Request)(f).FormValue(key), 32)
-       if len(defaults) > 0 && err != nil {
-               return defaults[0]
-       }
-       return float32(v)
-}
-
-// MustFloat64 returns request form as float64 with default
-func (f *Forms) MustFloat64(key string, defaults ...float64) float64 {
-       v, err := strconv.ParseFloat((*http.Request)(f).FormValue(key), 64)
-       if len(defaults) > 0 && err != nil {
-               return defaults[0]
-       }
+// FormInt64 returns the first value for the provided key in the form as an int64
+func (ctx *Context) FormInt64(key string) int64 {
+       v, _ := strconv.ParseInt(ctx.Req.FormValue(key), 10, 64)
        return v
 }
 
-// MustBool returns request form as bool with default
-func (f *Forms) MustBool(key string, defaults ...bool) bool {
-       v, err := strconv.ParseBool((*http.Request)(f).FormValue(key))
-       if len(defaults) > 0 && err != nil {
-               return defaults[0]
-       }
+// FormBool returns true if the value for the provided key in the form is "1" or "true"
+func (ctx *Context) FormBool(key string) bool {
+       v, _ := strconv.ParseBool(ctx.Req.FormValue(key))
        return v
 }
 
-// MustOptionalBool returns request form as OptionalBool with default
-func (f *Forms) MustOptionalBool(key string, defaults ...util.OptionalBool) util.OptionalBool {
-       value := (*http.Request)(f).FormValue(key)
+// FormOptionalBool returns an OptionalBoolTrue or OptionalBoolFalse if the value
+// for the provided key exists in the form else it returns OptionalBoolNone
+func (ctx *Context) FormOptionalBool(key string) util.OptionalBool {
+       value := ctx.Req.FormValue(key)
        if len(value) == 0 {
                return util.OptionalBoolNone
        }
-       v, err := strconv.ParseBool((*http.Request)(f).FormValue(key))
-       if len(defaults) > 0 && err != nil {
-               return defaults[0]
-       }
+       v, _ := strconv.ParseBool(ctx.Req.FormValue(key))
        return util.OptionalBoolOf(v)
 }
index abd9ca54814846b8a8a36fa3b47f9f1b4b7b0556..df7163835025476e4129befbeeaa9f48a2cf3858 100644 (file)
@@ -346,7 +346,7 @@ func repoAssignment(ctx *Context, repo *models.Repository) {
 
        // Check access.
        if ctx.Repo.Permission.AccessMode == models.AccessModeNone {
-               if ctx.Form("go-get") == "1" {
+               if ctx.FormString("go-get") == "1" {
                        EarlyResponseForGoGetMeta(ctx)
                        return
                }
@@ -415,7 +415,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
                owner, err = models.GetUserByName(userName)
                if err != nil {
                        if models.IsErrUserNotExist(err) {
-                               if ctx.Form("go-get") == "1" {
+                               if ctx.FormString("go-get") == "1" {
                                        EarlyResponseForGoGetMeta(ctx)
                                        return
                                }
@@ -437,7 +437,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
                        if err == nil {
                                RedirectToRepo(ctx, redirectRepoID)
                        } else if models.IsErrRepoRedirectNotExist(err) {
-                               if ctx.Form("go-get") == "1" {
+                               if ctx.FormString("go-get") == "1" {
                                        EarlyResponseForGoGetMeta(ctx)
                                        return
                                }
@@ -618,7 +618,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
                }
        }
 
-       if ctx.Form("go-get") == "1" {
+       if ctx.FormString("go-get") == "1" {
                ctx.Data["GoGetImport"] = ComposeGoGetImport(owner.Name, repo.Name)
                prefix := setting.AppURL + path.Join(owner.Name, repo.Name, "src", "branch", ctx.Repo.BranchName)
                ctx.Data["GoDocDirectory"] = prefix + "{/dir}"
index fb5888f083710ade7a42f47edee2fe473dba9d5d..062cee628320f1e8fbcb8519157fae2db483de04 100644 (file)
@@ -42,7 +42,7 @@ func ListUnadoptedRepositories(ctx *context.APIContext) {
        //     "$ref": "#/responses/forbidden"
 
        listOptions := utils.GetListOptions(ctx)
-       repoNames, count, err := repository.ListUnadoptedRepositories(ctx.Form("query"), &listOptions)
+       repoNames, count, err := repository.ListUnadoptedRepositories(ctx.FormString("query"), &listOptions)
        if err != nil {
                ctx.InternalServerError(err)
        }
index b2202254daa97a5159c03d4b25d5df0d00577a7b..6de47ddc7e0ac5f1316b83fb8caeedba528aa3ba 100644 (file)
@@ -93,7 +93,7 @@ import (
 
 func sudo() func(ctx *context.APIContext) {
        return func(ctx *context.APIContext) {
-               sudo := ctx.Form("sudo")
+               sudo := ctx.FormString("sudo")
                if len(sudo) == 0 {
                        sudo = ctx.Req.Header.Get("Sudo")
                }
index b5a6d8abf05f081def8203a38efb388800717b52..0bc48aeb1683592fad26040832dac34d9e37eb33 100644 (file)
@@ -171,7 +171,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
        //     "$ref": "#/responses/empty"
 
        lastRead := int64(0)
-       qLastRead := strings.Trim(ctx.Form("last_read_at"), " ")
+       qLastRead := strings.Trim(ctx.FormString("last_read_at"), " ")
        if len(qLastRead) > 0 {
                tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
                if err != nil {
@@ -200,7 +200,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
                return
        }
 
-       targetStatus := statusStringToNotificationStatus(ctx.Form("to-status"))
+       targetStatus := statusStringToNotificationStatus(ctx.FormString("to-status"))
        if targetStatus == 0 {
                targetStatus = models.NotificationStatusRead
        }
index 0865d121567a6e9e87fdeb3c70bf9d2d399cb473..1774c0b4124926a0b2d52359f20a38a5710cb99e 100644 (file)
@@ -82,7 +82,7 @@ func ReadThread(ctx *context.APIContext) {
                return
        }
 
-       targetStatus := statusStringToNotificationStatus(ctx.Form("to-status"))
+       targetStatus := statusStringToNotificationStatus(ctx.FormString("to-status"))
        if targetStatus == 0 {
                targetStatus = models.NotificationStatusRead
        }
index 184091544aceca769221616d1ee11f2257de363c..c4b126c56779b01f4dbefc3271da4d8cb2fba07f 100644 (file)
@@ -122,7 +122,7 @@ func ReadNotifications(ctx *context.APIContext) {
        //     "$ref": "#/responses/empty"
 
        lastRead := int64(0)
-       qLastRead := strings.Trim(ctx.Form("last_read_at"), " ")
+       qLastRead := strings.Trim(ctx.FormString("last_read_at"), " ")
        if len(qLastRead) > 0 {
                tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
                if err != nil {
@@ -147,7 +147,7 @@ func ReadNotifications(ctx *context.APIContext) {
                return
        }
 
-       targetStatus := statusStringToNotificationStatus(ctx.Form("to-status"))
+       targetStatus := statusStringToNotificationStatus(ctx.FormString("to-status"))
        if targetStatus == 0 {
                targetStatus = models.NotificationStatusRead
        }
index a66977ea5a78a03cb44e91fd4ac8a19c6c88d6fe..c70252158e9e87b20734c136950e3ae5a542ddea 100644 (file)
@@ -43,7 +43,7 @@ func ListLabels(ctx *context.APIContext) {
        //   "200":
        //     "$ref": "#/responses/LabelList"
 
-       labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.Form("sort"), utils.GetListOptions(ctx))
+       labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.FormString("sort"), utils.GetListOptions(ctx))
        if err != nil {
                ctx.Error(http.StatusInternalServerError, "GetLabelsByOrgID", err)
                return
index e967fc7612a8562dd0d55c964426cbe4f6daf421..7802bede1b0defae3db4a52b9baed44c0be24d50 100644 (file)
@@ -658,9 +658,9 @@ func SearchTeam(ctx *context.APIContext) {
 
        opts := &models.SearchTeamOptions{
                UserID:      ctx.User.ID,
-               Keyword:     strings.TrimSpace(ctx.Form("q")),
+               Keyword:     strings.TrimSpace(ctx.FormString("q")),
                OrgID:       ctx.Org.Organization.ID,
-               IncludeDesc: ctx.Form("include_desc") == "" || ctx.FormBool("include_desc"),
+               IncludeDesc: ctx.FormString("include_desc") == "" || ctx.FormBool("include_desc"),
                ListOptions: listOptions,
        }
 
index 9950a7d4567a18135b11933e8ed8687163e4133a..f2fd901efa9505d39d647f9c4b3f11563e77d1f0 100644 (file)
@@ -147,7 +147,7 @@ func GetAllCommits(ctx *context.APIContext) {
                listOptions.PageSize = setting.Git.CommitsRangeSize
        }
 
-       sha := ctx.Form("sha")
+       sha := ctx.FormString("sha")
 
        var baseCommit *git.Commit
        if len(sha) == 0 {
index 172ad480318aaa7037bd74c1daa66f9996ec869a..6add20cb09f9fb00f9cb2803bf1da304d7e75eea 100644 (file)
@@ -106,7 +106,7 @@ func SearchIssues(ctx *context.APIContext) {
        }
 
        var isClosed util.OptionalBool
-       switch ctx.Form("state") {
+       switch ctx.FormString("state") {
        case "closed":
                isClosed = util.OptionalBoolTrue
        case "all":
@@ -140,7 +140,7 @@ func SearchIssues(ctx *context.APIContext) {
        var issues []*models.Issue
        var filteredCount int64
 
-       keyword := strings.Trim(ctx.Form("q"), " ")
+       keyword := strings.Trim(ctx.FormString("q"), " ")
        if strings.IndexByte(keyword, 0) >= 0 {
                keyword = ""
        }
@@ -153,7 +153,7 @@ func SearchIssues(ctx *context.APIContext) {
        }
 
        var isPull util.OptionalBool
-       switch ctx.Form("type") {
+       switch ctx.FormString("type") {
        case "pulls":
                isPull = util.OptionalBoolTrue
        case "issues":
@@ -162,13 +162,13 @@ func SearchIssues(ctx *context.APIContext) {
                isPull = util.OptionalBoolNone
        }
 
-       labels := strings.TrimSpace(ctx.Form("labels"))
+       labels := strings.TrimSpace(ctx.FormString("labels"))
        var includedLabelNames []string
        if len(labels) > 0 {
                includedLabelNames = strings.Split(labels, ",")
        }
 
-       milestones := strings.TrimSpace(ctx.Form("milestones"))
+       milestones := strings.TrimSpace(ctx.FormString("milestones"))
        var includedMilestones []string
        if len(milestones) > 0 {
                includedMilestones = strings.Split(milestones, ",")
@@ -319,7 +319,7 @@ func ListIssues(ctx *context.APIContext) {
        }
 
        var isClosed util.OptionalBool
-       switch ctx.Form("state") {
+       switch ctx.FormString("state") {
        case "closed":
                isClosed = util.OptionalBoolTrue
        case "all":
@@ -331,7 +331,7 @@ func ListIssues(ctx *context.APIContext) {
        var issues []*models.Issue
        var filteredCount int64
 
-       keyword := strings.Trim(ctx.Form("q"), " ")
+       keyword := strings.Trim(ctx.FormString("q"), " ")
        if strings.IndexByte(keyword, 0) >= 0 {
                keyword = ""
        }
@@ -345,7 +345,7 @@ func ListIssues(ctx *context.APIContext) {
                }
        }
 
-       if splitted := strings.Split(ctx.Form("labels"), ","); len(splitted) > 0 {
+       if splitted := strings.Split(ctx.FormString("labels"), ","); len(splitted) > 0 {
                labelIDs, err = models.GetLabelIDsInRepoByNames(ctx.Repo.Repository.ID, splitted)
                if err != nil {
                        ctx.Error(http.StatusInternalServerError, "GetLabelIDsInRepoByNames", err)
@@ -354,7 +354,7 @@ func ListIssues(ctx *context.APIContext) {
        }
 
        var mileIDs []int64
-       if part := strings.Split(ctx.Form("milestones"), ","); len(part) > 0 {
+       if part := strings.Split(ctx.FormString("milestones"), ","); len(part) > 0 {
                for i := range part {
                        // uses names and fall back to ids
                        // non existent milestones are discarded
@@ -386,7 +386,7 @@ func ListIssues(ctx *context.APIContext) {
        listOptions := utils.GetListOptions(ctx)
 
        var isPull util.OptionalBool
-       switch ctx.Form("type") {
+       switch ctx.FormString("type") {
        case "pulls":
                isPull = util.OptionalBoolTrue
        case "issues":
@@ -448,7 +448,7 @@ func ListIssues(ctx *context.APIContext) {
 }
 
 func getUserIDForFilter(ctx *context.APIContext, queryName string) int64 {
-       userName := ctx.Form(queryName)
+       userName := ctx.FormString(queryName)
        if len(userName) == 0 {
                return 0
        }
index eaf2c44c7c05b79778d4985b2aaa4de07bfcb7f8..e2935fd13dfbdefc4170cbc0309182bfec9f2673 100644 (file)
@@ -90,7 +90,7 @@ func ListTrackedTimes(ctx *context.APIContext) {
                IssueID:      issue.ID,
        }
 
-       qUser := strings.Trim(ctx.Form("user"), " ")
+       qUser := strings.Trim(ctx.FormString("user"), " ")
        if qUser != "" {
                user, err := models.GetUserByName(qUser)
                if models.IsErrUserNotExist(err) {
@@ -500,7 +500,7 @@ func ListTrackedTimesByRepository(ctx *context.APIContext) {
        }
 
        // Filters
-       qUser := strings.Trim(ctx.Form("user"), " ")
+       qUser := strings.Trim(ctx.FormString("user"), " ")
        if qUser != "" {
                user, err := models.GetUserByName(qUser)
                if models.IsErrUserNotExist(err) {
index d41531dd58930a93207690650b923a85404ceb51..903cef7104ec83decd35762a065fa16113afdf7d 100644 (file)
@@ -78,7 +78,7 @@ func ListDeployKeys(ctx *context.APIContext) {
        var keys []*models.DeployKey
        var err error
 
-       fingerprint := ctx.Form("fingerprint")
+       fingerprint := ctx.FormString("fingerprint")
        keyID := ctx.FormInt64("key_id")
        if fingerprint != "" || keyID != 0 {
                keys, err = models.SearchDeployKeys(ctx.Repo.Repository.ID, keyID, fingerprint)
index 0d1368d18c5e9b09b98b37eb4f5120c3bb27d0be..ca0d8392b8cba917f2ed488aba32da961a5bfcb0 100644 (file)
@@ -49,7 +49,7 @@ func ListLabels(ctx *context.APIContext) {
        //   "200":
        //     "$ref": "#/responses/LabelList"
 
-       labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.Form("sort"), utils.GetListOptions(ctx))
+       labels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, ctx.FormString("sort"), utils.GetListOptions(ctx))
        if err != nil {
                ctx.Error(http.StatusInternalServerError, "GetLabelsByRepoID", err)
                return
index 1231c3eb2126239cef8cd4d1133d8e754d5d1de1..07b3897bc16c28f4f1b2a9f5e44ff66566cb0ec7 100644 (file)
@@ -60,8 +60,8 @@ func ListMilestones(ctx *context.APIContext) {
        milestones, err := models.GetMilestones(models.GetMilestonesOption{
                ListOptions: utils.GetListOptions(ctx),
                RepoID:      ctx.Repo.Repository.ID,
-               State:       api.StateType(ctx.Form("state")),
-               Name:        ctx.Form("name"),
+               State:       api.StateType(ctx.FormString("state")),
+               Name:        ctx.FormString("name"),
        })
        if err != nil {
                ctx.Error(http.StatusInternalServerError, "GetMilestones", err)
index 7986c47e6f80d819d37ae2d3b93957d58e33cc44..0834667657cfa3afd5e2c9c7af83bb18652fbf0e 100644 (file)
@@ -190,7 +190,7 @@ func CreateReleaseAttachment(ctx *context.APIContext) {
        }
 
        var filename = header.Filename
-       if query := ctx.Form("name"); query != "" {
+       if query := ctx.FormString("name"); query != "" {
                filename = query
        }
 
index 9c93408832e603c5880cfde232defd0a08746b8e..fb1472226f98f7275d1ec0038950d8b82e8a85a9 100644 (file)
@@ -135,19 +135,19 @@ func Search(ctx *context.APIContext) {
        opts := &models.SearchRepoOptions{
                ListOptions:        utils.GetListOptions(ctx),
                Actor:              ctx.User,
-               Keyword:            strings.Trim(ctx.Form("q"), " "),
+               Keyword:            strings.Trim(ctx.FormString("q"), " "),
                OwnerID:            ctx.FormInt64("uid"),
                PriorityOwnerID:    ctx.FormInt64("priority_owner_id"),
                TeamID:             ctx.FormInt64("team_id"),
                TopicOnly:          ctx.FormBool("topic"),
                Collaborate:        util.OptionalBoolNone,
-               Private:            ctx.IsSigned && (ctx.Form("private") == "" || ctx.FormBool("private")),
+               Private:            ctx.IsSigned && (ctx.FormString("private") == "" || ctx.FormBool("private")),
                Template:           util.OptionalBoolNone,
                StarredByID:        ctx.FormInt64("starredBy"),
                IncludeDescription: ctx.FormBool("includeDesc"),
        }
 
-       if ctx.Form("template") != "" {
+       if ctx.FormString("template") != "" {
                opts.Template = util.OptionalBoolOf(ctx.FormBool("template"))
        }
 
@@ -155,7 +155,7 @@ func Search(ctx *context.APIContext) {
                opts.Collaborate = util.OptionalBoolFalse
        }
 
-       var mode = ctx.Form("mode")
+       var mode = ctx.FormString("mode")
        switch mode {
        case "source":
                opts.Fork = util.OptionalBoolFalse
@@ -173,17 +173,17 @@ func Search(ctx *context.APIContext) {
                return
        }
 
-       if ctx.Form("archived") != "" {
+       if ctx.FormString("archived") != "" {
                opts.Archived = util.OptionalBoolOf(ctx.FormBool("archived"))
        }
 
-       if ctx.Form("is_private") != "" {
+       if ctx.FormString("is_private") != "" {
                opts.IsPrivate = util.OptionalBoolOf(ctx.FormBool("is_private"))
        }
 
-       var sortMode = ctx.Form("sort")
+       var sortMode = ctx.FormString("sort")
        if len(sortMode) > 0 {
-               var sortOrder = ctx.Form("order")
+               var sortOrder = ctx.FormString("order")
                if len(sortOrder) == 0 {
                        sortOrder = "asc"
                }
index 7646eaf82e33a6fae1fdf4aefc7e1c24d99e77c5..a7c52e0bccbd77c02ef508fa861fc20935a108ea 100644 (file)
@@ -274,7 +274,7 @@ func TopicSearch(ctx *context.APIContext) {
                return
        }
 
-       kw := ctx.Form("q")
+       kw := ctx.FormString("q")
 
        listOptions := utils.GetListOptions(ctx)
 
index 284653b108e41ffdffe337e2cc722ed1fe77d672..04252524b729fee3c80e44ecc2ffa4823e2cf241 100644 (file)
@@ -48,7 +48,7 @@ func listPublicKeys(ctx *context.APIContext, user *models.User) {
        var keys []*models.PublicKey
        var err error
 
-       fingerprint := ctx.Form("fingerprint")
+       fingerprint := ctx.FormString("fingerprint")
        username := ctx.Params("username")
 
        if fingerprint != "" {
index de1fd5a5c5834545b539e160f1764f3232dd401b..db950bd1ee4961927ae64edaba8e4a9da38f68b3 100644 (file)
@@ -58,7 +58,7 @@ func Search(ctx *context.APIContext) {
 
        opts := &models.SearchUserOptions{
                Actor:       ctx.User,
-               Keyword:     strings.Trim(ctx.Form("q"), " "),
+               Keyword:     strings.Trim(ctx.FormString("q"), " "),
                UID:         ctx.FormInt64("uid"),
                Type:        models.UserTypeIndividual,
                ListOptions: listOptions,
index ee70723bd1e63dbda08b16f878030477ce72ef75..81f5086c9611c88e4670afc3c1dc686b3b154029 100644 (file)
@@ -54,7 +54,7 @@ func parseTime(value string) (int64, error) {
 
 // prepareQueryArg unescape and trim a query arg
 func prepareQueryArg(ctx *context.APIContext, name string) (value string, err error) {
-       value, err = url.PathUnescape(ctx.Form(name))
+       value, err = url.PathUnescape(ctx.FormString(name))
        value = strings.TrimSpace(value)
        return
 }
index 1e60af232ae2483fe1af351f8134816b35994090..4f518e41f0dfa2adb3e9348f0a5093fa6f385d58 100644 (file)
@@ -50,7 +50,7 @@ func UpdatePublicKeyInRepo(ctx *context.PrivateContext) {
 // AuthorizedPublicKeyByContent searches content as prefix (leak e-mail part)
 // and returns public key found.
 func AuthorizedPublicKeyByContent(ctx *context.PrivateContext) {
-       content := ctx.Form("content")
+       content := ctx.FormString("content")
 
        publicKey, err := models.SearchPublicKeyByContent(content)
        if err != nil {
index 5db4331228896d4f1486aa905c3dd2a2902a256b..ce177ea090872f06409c250ae5ecee927af6311a 100644 (file)
@@ -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
index c2fb474477db0dca70def95598799264b2043e40..017d696e202de43616030464d191eecc64527591 100644 (file)
@@ -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)
index 34b7af2690373d9006c3f3e994c2fda7174c108d..15d4554957e54f08da29593d7eaa3bf83f28b4ce 100644 (file)
@@ -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 {
index 5dd8298b2d39acc2bb21d5514afbc2e6fccfb875..55a4409145a74e9e59cf7ea586bb8cf39a7de2bc 100644 (file)
@@ -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 (
index faac639caab6d2088b1fb4bc5850457fce1292bf..83fb721a7debae0b81ca79d6bdc1b658109fa50c 100644 (file)
@@ -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
 
index 85c45c7effc8a56a6f29c6ef8d5fd41c20d13ac6..06dcdb3c6a61160e1929787e140517f203b2b53d 100644 (file)
@@ -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)
index 1680153b49cfed0e0f2feeadae8b5b0adf1f156f..02adf9c5ea5d1f3d3ab8ca13d297a58d85e27463 100644 (file)
@@ -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
        }
 
index 8c1475d4698e78ea88b62663d578db2399029f33..de131d27b6b492e6bc2c379b82a3f30c44d04c80 100644 (file)
@@ -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")
index 08457d4f8eb01ca04b9869bd9525b5565c64bcd1..97a5437c61ee84c20e5c8e7d119495ac3f87980a 100644 (file)
@@ -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
index 47a80ec50fe8269a901d89d32a1a01e2640d1d87..b21b94d64d67cccd6e3606911462b2c88ae14488 100644 (file)
@@ -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
index a61315e05c1f2a117af50e85fd15a10fde0a1baa..4725f19b3dbda3c5f49faa494799249097d9ee41 100644 (file)
@@ -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 {
index a57cf633e688d939fb282e00688140f128f44301..1a25384792c24bf4b2bd355f3bad86cf25651f9e 100644 (file)
@@ -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())
index f89a5543c119dead5790d45c79502606746b0e02..84c386466932928c3737880b9a85be48ee7951f7 100644 (file)
@@ -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 {
index e1d93a243585a66ac5c0f4b7db3fc67ab4bbf2f3..57ee7a204345e182594267a64a0260fbe714a0cb 100644 (file)
@@ -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
index 511a74cdd54c40c08c8b83cedbaa6174a2342101..ec65813656fe54672c90f6137bbc8e5489bb79c5 100644 (file)
@@ -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)
index 82bf039c0d831f59ee51d8ef24e571ef0111be20..6078d764b6fa1d793871fcfdb1a8bda18835acd3 100644 (file)
@@ -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
index 724ce5c774bafb68f16fb56bb7749a2ab4b233d9..248ae5b1329d5507e1cf283d84d55f050390d0db 100644 (file)
@@ -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)
index 4ce8e17e1bb0259423be3274d45f03cb7e71da02..abb529649a5b9d7acf912b803b33ec2da0d34db0 100644 (file)
@@ -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 {
index e41319d71e5ac8ebe050531657c1e78754974243..e524a9209a48a3506764ca6b0b0120b0ff7d1749 100644 (file)
@@ -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
index 7625fbde32addad2186758a9d9709c4c427ea61b..250544350416fa3e7248208f15fcb3b77d89200f 100644 (file)
@@ -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
index 167b12e5625ec6523e35bfc23881aaf352d166f0..3d710d044894871a2db4a42392f466683e9e4963 100644 (file)
@@ -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() {
index c8eda6668093c7c99250a3eda08e71a995af4d11..675cfef0aa69def8a172f3eb53a438dcab2417de 100644 (file)
@@ -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 {
index ccdd670e6a603e589d926abc2099f9789c5ec0b2..2fa5ab9186ad24fdff9e1a6b82b0989f43087e81 100644 (file)
@@ -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")
index b087e40ce616c7804d67b24878cf854a21679838..257aa737f652757715ef29df6b58909d051017cc 100644 (file)
@@ -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)
index d0e59c8fa48bc624ff819d9fc423e8e4b31709e2..d1d904bcd9cb0151dcb202a452c4463f7e7c092f 100644 (file)
@@ -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)
index d2c1a0c399d7cf9c2bbe8998ce45de4880b830b8..98f60c6b59122e9e7c59a7888012c71f147d78da 100644 (file)
@@ -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 {
index 6fbc4fb4d5fbeda5da71143c414afc4139daec34..02dd257cda0a7e899a0175ee0231cd5b895b8602 100644 (file)
@@ -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},
index c1c49e8ac6778ac1481d6ef542057a248aeb336b..2f1561073770aefa27a49bbf234e90b0b4725593 100644 (file)
@@ -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
index 7a1a3d0bcf43094003d53f13323e707fe5e8954b..30c7d81b8e782adc9b717306085ff008b8182209 100644 (file)
@@ -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
index 5a24d7b2b62985d52b19247696220c25a2cdd047..2a2a04c11189b2defd2e8e509381fd2b5e955110 100644 (file)
@@ -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, ",")
        }
index b0c8ba970a1464a5c4014f4d5045a9426905a3de..6c8645226f643e3d1fbf3ce1b0d3596d97c45d11 100644 (file)
@@ -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
index 72e990f661de4e481e0cb91ff644a4bb0a30e61f..a9e60bb07cbc2cdf50650a9e1c12a0e8ad288c8a 100644 (file)
@@ -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.
index 9106f012ff93a8be8a61e80433204b78aca212f7..fc419a7f6ea633df88a83c62e4557b26b1188351 100644 (file)
@@ -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 {
index 3b8984072012179469ffbf4229f783285e0d3d60..285f1ff3672a8ad8a35b6bb6b678502802c7bac0 100644 (file)
@@ -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)
index 0a43cbbf271dc6f796de6032a9771f5c4e074407..bc017db9d482fed6c996bba528be015156158a96 100644 (file)
@@ -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)
        }
 
index cb14347886fd5eefee5a8a1f1e9b5446d351c038..e6a8e5b5a8a9d438e9cbf65b30d5dd91dfac2394 100644 (file)
@@ -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())
 }
index ea349949f98ac938da38e9b8a0101551bc5a9c36..6201078954412554a7297eaf52c1ea572724e00f 100644 (file)
@@ -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)
 
index 8ade9c4257e86d2967a5dc0cfcda111ab09563b9..e45a8a132465aee0d59216a2562e39a8399fc523 100644 (file)
@@ -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))
index c1ea87cabc5beb4b605dac28e56d30255fe7e7d7..24b9a9e205a0c8d21f89307d9b6e61c869e753e7 100644 (file)
@@ -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")
 }
index 36c6d7df7276ed06b1a9706f03eb43163810ecf8..3406194015f65bb52b0ad4f8f3466d9c3924d0a3 100644 (file)
@@ -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
        }
index be91dcc04053ccff34a4c02fef9673596c4e97d9..ac72fff6af71f1f10bf63bda3b15119ad232de2d 100644 (file)
@@ -78,7 +78,7 @@ func GetListLockHandler(ctx *context.Context) {
        } else if limit < 0 {
                limit = 0
        }
-       id := ctx.Form("id")
+       id := ctx.FormString("id")
        if id != "" { //Case where we request a specific id
                v, err := strconv.ParseInt(id, 10, 64)
                if err != nil {
@@ -95,7 +95,7 @@ func GetListLockHandler(ctx *context.Context) {
                return
        }
 
-       path := ctx.Form("path")
+       path := ctx.FormString("path")
        if path != "" { //Case where we request a specific id
                lock, err := models.GetLFSLock(repository, path)
                if err != nil && !models.IsErrLFSLockNotExist(err) {