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
This commit is contained in:
6543 2021-08-11 02:31:13 +02:00 committed by GitHub
parent 2eeae4edb6
commit c4d70a0325
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 236 additions and 449 deletions

View file

@ -28,7 +28,6 @@ import (
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates" "code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/translation" "code.gitea.io/gitea/modules/translation"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/modules/web/middleware" "code.gitea.io/gitea/modules/web/middleware"
"code.gitea.io/gitea/services/auth" "code.gitea.io/gitea/services/auth"
@ -287,41 +286,6 @@ func (ctx *Context) Header() http.Header {
return ctx.Resp.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 // HandleText handles HTTP status code
func (ctx *Context) HandleText(status int, title string) { func (ctx *Context) HandleText(status int, title string) {
if (status/100 == 4) || (status/100 == 5) { if (status/100 == 4) || (status/100 == 5) {

View file

@ -5,237 +5,60 @@
package context package context
import ( import (
"errors"
"net/http"
"net/url"
"strconv" "strconv"
"strings" "strings"
"text/template"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/util"
) )
// Forms a new enhancement of http.Request // FormString returns the first value matching the provided key in the form as a string
type Forms http.Request func (ctx *Context) FormString(key string) string {
return ctx.Req.FormValue(key)
// Values returns http.Request values
func (f *Forms) Values() url.Values {
return (*http.Request)(f).Form
} }
// String returns request form as string // FormStrings returns a string slice for the provided key from the form
func (f *Forms) String(key string) (string, error) { func (ctx *Context) FormStrings(key string) []string {
return (*http.Request)(f).FormValue(key), nil if ctx.Req.Form == nil {
} if err := ctx.Req.ParseMultipartForm(32 << 20); err != nil {
return 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
}
// 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
} }
} }
if v, ok := (*http.Request)(f).Form[key]; ok { if v, ok := ctx.Req.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 {
return v return v
} }
if len(defaults) > 0 { return nil
return defaults[0]
}
return ""
} }
// MustTrimmed returns request form as string with default // FormTrim returns the first value for the provided key in the form as a space trimmed string
func (f *Forms) MustTrimmed(key string, defaults ...string) string { func (ctx *Context) FormTrim(key string) string {
return strings.TrimSpace(f.MustString(key, defaults...)) return strings.TrimSpace(ctx.Req.FormValue(key))
} }
// MustStrings returns request form as strings with default // FormInt returns the first value for the provided key in the form as an int
func (f *Forms) MustStrings(key string, defaults ...[]string) []string { func (ctx *Context) FormInt(key string) int {
if (*http.Request)(f).Form == nil { v, _ := strconv.Atoi(ctx.Req.FormValue(key))
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 return v
} }
// MustInt32 returns request form as int32 with default // FormInt64 returns the first value for the provided key in the form as an int64
func (f *Forms) MustInt32(key string, defaults ...int32) int32 { func (ctx *Context) FormInt64(key string) int64 {
v, err := strconv.ParseInt((*http.Request)(f).FormValue(key), 10, 32) v, _ := strconv.ParseInt(ctx.Req.FormValue(key), 10, 64)
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]
}
return v return v
} }
// MustUint returns request form as uint with default // FormBool returns true if the value for the provided key in the form is "1" or "true"
func (f *Forms) MustUint(key string, defaults ...uint) uint { func (ctx *Context) FormBool(key string) bool {
v, err := strconv.ParseUint((*http.Request)(f).FormValue(key), 10, 64) v, _ := strconv.ParseBool(ctx.Req.FormValue(key))
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 return v
} }
// MustFloat32 returns request form as float32 with default // FormOptionalBool returns an OptionalBoolTrue or OptionalBoolFalse if the value
func (f *Forms) MustFloat32(key string, defaults ...float32) float32 { // for the provided key exists in the form else it returns OptionalBoolNone
v, err := strconv.ParseFloat((*http.Request)(f).FormValue(key), 32) func (ctx *Context) FormOptionalBool(key string) util.OptionalBool {
if len(defaults) > 0 && err != nil { value := ctx.Req.FormValue(key)
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]
}
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]
}
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)
if len(value) == 0 { if len(value) == 0 {
return util.OptionalBoolNone return util.OptionalBoolNone
} }
v, err := strconv.ParseBool((*http.Request)(f).FormValue(key)) v, _ := strconv.ParseBool(ctx.Req.FormValue(key))
if len(defaults) > 0 && err != nil {
return defaults[0]
}
return util.OptionalBoolOf(v) return util.OptionalBoolOf(v)
} }

View file

@ -346,7 +346,7 @@ func repoAssignment(ctx *Context, repo *models.Repository) {
// Check access. // Check access.
if ctx.Repo.Permission.AccessMode == models.AccessModeNone { if ctx.Repo.Permission.AccessMode == models.AccessModeNone {
if ctx.Form("go-get") == "1" { if ctx.FormString("go-get") == "1" {
EarlyResponseForGoGetMeta(ctx) EarlyResponseForGoGetMeta(ctx)
return return
} }
@ -415,7 +415,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
owner, err = models.GetUserByName(userName) owner, err = models.GetUserByName(userName)
if err != nil { if err != nil {
if models.IsErrUserNotExist(err) { if models.IsErrUserNotExist(err) {
if ctx.Form("go-get") == "1" { if ctx.FormString("go-get") == "1" {
EarlyResponseForGoGetMeta(ctx) EarlyResponseForGoGetMeta(ctx)
return return
} }
@ -437,7 +437,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
if err == nil { if err == nil {
RedirectToRepo(ctx, redirectRepoID) RedirectToRepo(ctx, redirectRepoID)
} else if models.IsErrRepoRedirectNotExist(err) { } else if models.IsErrRepoRedirectNotExist(err) {
if ctx.Form("go-get") == "1" { if ctx.FormString("go-get") == "1" {
EarlyResponseForGoGetMeta(ctx) EarlyResponseForGoGetMeta(ctx)
return 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) ctx.Data["GoGetImport"] = ComposeGoGetImport(owner.Name, repo.Name)
prefix := setting.AppURL + path.Join(owner.Name, repo.Name, "src", "branch", ctx.Repo.BranchName) prefix := setting.AppURL + path.Join(owner.Name, repo.Name, "src", "branch", ctx.Repo.BranchName)
ctx.Data["GoDocDirectory"] = prefix + "{/dir}" ctx.Data["GoDocDirectory"] = prefix + "{/dir}"

View file

@ -42,7 +42,7 @@ func ListUnadoptedRepositories(ctx *context.APIContext) {
// "$ref": "#/responses/forbidden" // "$ref": "#/responses/forbidden"
listOptions := utils.GetListOptions(ctx) 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 { if err != nil {
ctx.InternalServerError(err) ctx.InternalServerError(err)
} }

View file

@ -93,7 +93,7 @@ import (
func sudo() func(ctx *context.APIContext) { func sudo() func(ctx *context.APIContext) {
return func(ctx *context.APIContext) { return func(ctx *context.APIContext) {
sudo := ctx.Form("sudo") sudo := ctx.FormString("sudo")
if len(sudo) == 0 { if len(sudo) == 0 {
sudo = ctx.Req.Header.Get("Sudo") sudo = ctx.Req.Header.Get("Sudo")
} }

View file

@ -171,7 +171,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
// "$ref": "#/responses/empty" // "$ref": "#/responses/empty"
lastRead := int64(0) lastRead := int64(0)
qLastRead := strings.Trim(ctx.Form("last_read_at"), " ") qLastRead := strings.Trim(ctx.FormString("last_read_at"), " ")
if len(qLastRead) > 0 { if len(qLastRead) > 0 {
tmpLastRead, err := time.Parse(time.RFC3339, qLastRead) tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
if err != nil { if err != nil {
@ -200,7 +200,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
return return
} }
targetStatus := statusStringToNotificationStatus(ctx.Form("to-status")) targetStatus := statusStringToNotificationStatus(ctx.FormString("to-status"))
if targetStatus == 0 { if targetStatus == 0 {
targetStatus = models.NotificationStatusRead targetStatus = models.NotificationStatusRead
} }

View file

@ -82,7 +82,7 @@ func ReadThread(ctx *context.APIContext) {
return return
} }
targetStatus := statusStringToNotificationStatus(ctx.Form("to-status")) targetStatus := statusStringToNotificationStatus(ctx.FormString("to-status"))
if targetStatus == 0 { if targetStatus == 0 {
targetStatus = models.NotificationStatusRead targetStatus = models.NotificationStatusRead
} }

View file

@ -122,7 +122,7 @@ func ReadNotifications(ctx *context.APIContext) {
// "$ref": "#/responses/empty" // "$ref": "#/responses/empty"
lastRead := int64(0) lastRead := int64(0)
qLastRead := strings.Trim(ctx.Form("last_read_at"), " ") qLastRead := strings.Trim(ctx.FormString("last_read_at"), " ")
if len(qLastRead) > 0 { if len(qLastRead) > 0 {
tmpLastRead, err := time.Parse(time.RFC3339, qLastRead) tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
if err != nil { if err != nil {
@ -147,7 +147,7 @@ func ReadNotifications(ctx *context.APIContext) {
return return
} }
targetStatus := statusStringToNotificationStatus(ctx.Form("to-status")) targetStatus := statusStringToNotificationStatus(ctx.FormString("to-status"))
if targetStatus == 0 { if targetStatus == 0 {
targetStatus = models.NotificationStatusRead targetStatus = models.NotificationStatusRead
} }

View file

@ -43,7 +43,7 @@ func ListLabels(ctx *context.APIContext) {
// "200": // "200":
// "$ref": "#/responses/LabelList" // "$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 { if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsByOrgID", err) ctx.Error(http.StatusInternalServerError, "GetLabelsByOrgID", err)
return return

View file

@ -658,9 +658,9 @@ func SearchTeam(ctx *context.APIContext) {
opts := &models.SearchTeamOptions{ opts := &models.SearchTeamOptions{
UserID: ctx.User.ID, UserID: ctx.User.ID,
Keyword: strings.TrimSpace(ctx.Form("q")), Keyword: strings.TrimSpace(ctx.FormString("q")),
OrgID: ctx.Org.Organization.ID, 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, ListOptions: listOptions,
} }

View file

@ -147,7 +147,7 @@ func GetAllCommits(ctx *context.APIContext) {
listOptions.PageSize = setting.Git.CommitsRangeSize listOptions.PageSize = setting.Git.CommitsRangeSize
} }
sha := ctx.Form("sha") sha := ctx.FormString("sha")
var baseCommit *git.Commit var baseCommit *git.Commit
if len(sha) == 0 { if len(sha) == 0 {

View file

@ -106,7 +106,7 @@ func SearchIssues(ctx *context.APIContext) {
} }
var isClosed util.OptionalBool var isClosed util.OptionalBool
switch ctx.Form("state") { switch ctx.FormString("state") {
case "closed": case "closed":
isClosed = util.OptionalBoolTrue isClosed = util.OptionalBoolTrue
case "all": case "all":
@ -140,7 +140,7 @@ func SearchIssues(ctx *context.APIContext) {
var issues []*models.Issue var issues []*models.Issue
var filteredCount int64 var filteredCount int64
keyword := strings.Trim(ctx.Form("q"), " ") keyword := strings.Trim(ctx.FormString("q"), " ")
if strings.IndexByte(keyword, 0) >= 0 { if strings.IndexByte(keyword, 0) >= 0 {
keyword = "" keyword = ""
} }
@ -153,7 +153,7 @@ func SearchIssues(ctx *context.APIContext) {
} }
var isPull util.OptionalBool var isPull util.OptionalBool
switch ctx.Form("type") { switch ctx.FormString("type") {
case "pulls": case "pulls":
isPull = util.OptionalBoolTrue isPull = util.OptionalBoolTrue
case "issues": case "issues":
@ -162,13 +162,13 @@ func SearchIssues(ctx *context.APIContext) {
isPull = util.OptionalBoolNone isPull = util.OptionalBoolNone
} }
labels := strings.TrimSpace(ctx.Form("labels")) labels := strings.TrimSpace(ctx.FormString("labels"))
var includedLabelNames []string var includedLabelNames []string
if len(labels) > 0 { if len(labels) > 0 {
includedLabelNames = strings.Split(labels, ",") includedLabelNames = strings.Split(labels, ",")
} }
milestones := strings.TrimSpace(ctx.Form("milestones")) milestones := strings.TrimSpace(ctx.FormString("milestones"))
var includedMilestones []string var includedMilestones []string
if len(milestones) > 0 { if len(milestones) > 0 {
includedMilestones = strings.Split(milestones, ",") includedMilestones = strings.Split(milestones, ",")
@ -319,7 +319,7 @@ func ListIssues(ctx *context.APIContext) {
} }
var isClosed util.OptionalBool var isClosed util.OptionalBool
switch ctx.Form("state") { switch ctx.FormString("state") {
case "closed": case "closed":
isClosed = util.OptionalBoolTrue isClosed = util.OptionalBoolTrue
case "all": case "all":
@ -331,7 +331,7 @@ func ListIssues(ctx *context.APIContext) {
var issues []*models.Issue var issues []*models.Issue
var filteredCount int64 var filteredCount int64
keyword := strings.Trim(ctx.Form("q"), " ") keyword := strings.Trim(ctx.FormString("q"), " ")
if strings.IndexByte(keyword, 0) >= 0 { if strings.IndexByte(keyword, 0) >= 0 {
keyword = "" 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) labelIDs, err = models.GetLabelIDsInRepoByNames(ctx.Repo.Repository.ID, splitted)
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelIDsInRepoByNames", err) ctx.Error(http.StatusInternalServerError, "GetLabelIDsInRepoByNames", err)
@ -354,7 +354,7 @@ func ListIssues(ctx *context.APIContext) {
} }
var mileIDs []int64 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 { for i := range part {
// uses names and fall back to ids // uses names and fall back to ids
// non existent milestones are discarded // non existent milestones are discarded
@ -386,7 +386,7 @@ func ListIssues(ctx *context.APIContext) {
listOptions := utils.GetListOptions(ctx) listOptions := utils.GetListOptions(ctx)
var isPull util.OptionalBool var isPull util.OptionalBool
switch ctx.Form("type") { switch ctx.FormString("type") {
case "pulls": case "pulls":
isPull = util.OptionalBoolTrue isPull = util.OptionalBoolTrue
case "issues": case "issues":
@ -448,7 +448,7 @@ func ListIssues(ctx *context.APIContext) {
} }
func getUserIDForFilter(ctx *context.APIContext, queryName string) int64 { func getUserIDForFilter(ctx *context.APIContext, queryName string) int64 {
userName := ctx.Form(queryName) userName := ctx.FormString(queryName)
if len(userName) == 0 { if len(userName) == 0 {
return 0 return 0
} }

View file

@ -90,7 +90,7 @@ func ListTrackedTimes(ctx *context.APIContext) {
IssueID: issue.ID, IssueID: issue.ID,
} }
qUser := strings.Trim(ctx.Form("user"), " ") qUser := strings.Trim(ctx.FormString("user"), " ")
if qUser != "" { if qUser != "" {
user, err := models.GetUserByName(qUser) user, err := models.GetUserByName(qUser)
if models.IsErrUserNotExist(err) { if models.IsErrUserNotExist(err) {
@ -500,7 +500,7 @@ func ListTrackedTimesByRepository(ctx *context.APIContext) {
} }
// Filters // Filters
qUser := strings.Trim(ctx.Form("user"), " ") qUser := strings.Trim(ctx.FormString("user"), " ")
if qUser != "" { if qUser != "" {
user, err := models.GetUserByName(qUser) user, err := models.GetUserByName(qUser)
if models.IsErrUserNotExist(err) { if models.IsErrUserNotExist(err) {

View file

@ -78,7 +78,7 @@ func ListDeployKeys(ctx *context.APIContext) {
var keys []*models.DeployKey var keys []*models.DeployKey
var err error var err error
fingerprint := ctx.Form("fingerprint") fingerprint := ctx.FormString("fingerprint")
keyID := ctx.FormInt64("key_id") keyID := ctx.FormInt64("key_id")
if fingerprint != "" || keyID != 0 { if fingerprint != "" || keyID != 0 {
keys, err = models.SearchDeployKeys(ctx.Repo.Repository.ID, keyID, fingerprint) keys, err = models.SearchDeployKeys(ctx.Repo.Repository.ID, keyID, fingerprint)

View file

@ -49,7 +49,7 @@ func ListLabels(ctx *context.APIContext) {
// "200": // "200":
// "$ref": "#/responses/LabelList" // "$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 { if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelsByRepoID", err) ctx.Error(http.StatusInternalServerError, "GetLabelsByRepoID", err)
return return

View file

@ -60,8 +60,8 @@ func ListMilestones(ctx *context.APIContext) {
milestones, err := models.GetMilestones(models.GetMilestonesOption{ milestones, err := models.GetMilestones(models.GetMilestonesOption{
ListOptions: utils.GetListOptions(ctx), ListOptions: utils.GetListOptions(ctx),
RepoID: ctx.Repo.Repository.ID, RepoID: ctx.Repo.Repository.ID,
State: api.StateType(ctx.Form("state")), State: api.StateType(ctx.FormString("state")),
Name: ctx.Form("name"), Name: ctx.FormString("name"),
}) })
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, "GetMilestones", err) ctx.Error(http.StatusInternalServerError, "GetMilestones", err)

View file

@ -190,7 +190,7 @@ func CreateReleaseAttachment(ctx *context.APIContext) {
} }
var filename = header.Filename var filename = header.Filename
if query := ctx.Form("name"); query != "" { if query := ctx.FormString("name"); query != "" {
filename = query filename = query
} }

View file

@ -135,19 +135,19 @@ func Search(ctx *context.APIContext) {
opts := &models.SearchRepoOptions{ opts := &models.SearchRepoOptions{
ListOptions: utils.GetListOptions(ctx), ListOptions: utils.GetListOptions(ctx),
Actor: ctx.User, Actor: ctx.User,
Keyword: strings.Trim(ctx.Form("q"), " "), Keyword: strings.Trim(ctx.FormString("q"), " "),
OwnerID: ctx.FormInt64("uid"), OwnerID: ctx.FormInt64("uid"),
PriorityOwnerID: ctx.FormInt64("priority_owner_id"), PriorityOwnerID: ctx.FormInt64("priority_owner_id"),
TeamID: ctx.FormInt64("team_id"), TeamID: ctx.FormInt64("team_id"),
TopicOnly: ctx.FormBool("topic"), TopicOnly: ctx.FormBool("topic"),
Collaborate: util.OptionalBoolNone, Collaborate: util.OptionalBoolNone,
Private: ctx.IsSigned && (ctx.Form("private") == "" || ctx.FormBool("private")), Private: ctx.IsSigned && (ctx.FormString("private") == "" || ctx.FormBool("private")),
Template: util.OptionalBoolNone, Template: util.OptionalBoolNone,
StarredByID: ctx.FormInt64("starredBy"), StarredByID: ctx.FormInt64("starredBy"),
IncludeDescription: ctx.FormBool("includeDesc"), IncludeDescription: ctx.FormBool("includeDesc"),
} }
if ctx.Form("template") != "" { if ctx.FormString("template") != "" {
opts.Template = util.OptionalBoolOf(ctx.FormBool("template")) opts.Template = util.OptionalBoolOf(ctx.FormBool("template"))
} }
@ -155,7 +155,7 @@ func Search(ctx *context.APIContext) {
opts.Collaborate = util.OptionalBoolFalse opts.Collaborate = util.OptionalBoolFalse
} }
var mode = ctx.Form("mode") var mode = ctx.FormString("mode")
switch mode { switch mode {
case "source": case "source":
opts.Fork = util.OptionalBoolFalse opts.Fork = util.OptionalBoolFalse
@ -173,17 +173,17 @@ func Search(ctx *context.APIContext) {
return return
} }
if ctx.Form("archived") != "" { if ctx.FormString("archived") != "" {
opts.Archived = util.OptionalBoolOf(ctx.FormBool("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")) opts.IsPrivate = util.OptionalBoolOf(ctx.FormBool("is_private"))
} }
var sortMode = ctx.Form("sort") var sortMode = ctx.FormString("sort")
if len(sortMode) > 0 { if len(sortMode) > 0 {
var sortOrder = ctx.Form("order") var sortOrder = ctx.FormString("order")
if len(sortOrder) == 0 { if len(sortOrder) == 0 {
sortOrder = "asc" sortOrder = "asc"
} }

View file

@ -274,7 +274,7 @@ func TopicSearch(ctx *context.APIContext) {
return return
} }
kw := ctx.Form("q") kw := ctx.FormString("q")
listOptions := utils.GetListOptions(ctx) listOptions := utils.GetListOptions(ctx)

View file

@ -48,7 +48,7 @@ func listPublicKeys(ctx *context.APIContext, user *models.User) {
var keys []*models.PublicKey var keys []*models.PublicKey
var err error var err error
fingerprint := ctx.Form("fingerprint") fingerprint := ctx.FormString("fingerprint")
username := ctx.Params("username") username := ctx.Params("username")
if fingerprint != "" { if fingerprint != "" {

View file

@ -58,7 +58,7 @@ func Search(ctx *context.APIContext) {
opts := &models.SearchUserOptions{ opts := &models.SearchUserOptions{
Actor: ctx.User, Actor: ctx.User,
Keyword: strings.Trim(ctx.Form("q"), " "), Keyword: strings.Trim(ctx.FormString("q"), " "),
UID: ctx.FormInt64("uid"), UID: ctx.FormInt64("uid"),
Type: models.UserTypeIndividual, Type: models.UserTypeIndividual,
ListOptions: listOptions, ListOptions: listOptions,

View file

@ -54,7 +54,7 @@ func parseTime(value string) (int64, error) {
// prepareQueryArg unescape and trim a query arg // prepareQueryArg unescape and trim a query arg
func prepareQueryArg(ctx *context.APIContext, name string) (value string, err error) { 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) value = strings.TrimSpace(value)
return return
} }

View file

@ -50,7 +50,7 @@ func UpdatePublicKeyInRepo(ctx *context.PrivateContext) {
// AuthorizedPublicKeyByContent searches content as prefix (leak e-mail part) // AuthorizedPublicKeyByContent searches content as prefix (leak e-mail part)
// and returns public key found. // and returns public key found.
func AuthorizedPublicKeyByContent(ctx *context.PrivateContext) { func AuthorizedPublicKeyByContent(ctx *context.PrivateContext) {
content := ctx.Form("content") content := ctx.FormString("content")
publicKey, err := models.SearchPublicKeyByContent(content) publicKey, err := models.SearchPublicKeyByContent(content)
if err != nil { if err != nil {

View file

@ -161,7 +161,7 @@ func DashboardPost(ctx *context.Context) {
// SendTestMail send test mail to confirm mail service is OK // SendTestMail send test mail to confirm mail service is OK
func SendTestMail(ctx *context.Context) { 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 // Send a test email to the user's email address and redirect back to Config
if err := mailer.SendTestMail(email); err != nil { if err := mailer.SendTestMail(email); err != nil {
ctx.Flash.Error(ctx.Tr("admin.config.test_mail_failed", email, err)) ctx.Flash.Error(ctx.Tr("admin.config.test_mail_failed", email, err))
@ -377,7 +377,7 @@ func Flush(ctx *context.Context) {
ctx.Status(404) ctx.Status(404)
return return
} }
timeout, err := time.ParseDuration(ctx.Form("timeout")) timeout, err := time.ParseDuration(ctx.FormString("timeout"))
if err != nil { if err != nil {
timeout = -1 timeout = -1
} }
@ -405,7 +405,7 @@ func AddWorkers(ctx *context.Context) {
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10)) ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
return return
} }
timeout, err := time.ParseDuration(ctx.Form("timeout")) timeout, err := time.ParseDuration(ctx.FormString("timeout"))
if err != nil { if err != nil {
ctx.Flash.Error(ctx.Tr("admin.monitor.queue.pool.addworkers.musttimeoutduration")) ctx.Flash.Error(ctx.Tr("admin.monitor.queue.pool.addworkers.musttimeoutduration"))
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10)) ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
@ -435,9 +435,9 @@ func SetQueueSettings(ctx *context.Context) {
return return
} }
maxNumberStr := ctx.Form("max-number") maxNumberStr := ctx.FormString("max-number")
numberStr := ctx.Form("number") numberStr := ctx.FormString("number")
timeoutStr := ctx.Form("timeout") timeoutStr := ctx.FormString("timeout")
var err error var err error
var maxNumber, number int var maxNumber, number int

View file

@ -51,8 +51,8 @@ func Emails(ctx *context.Context) {
orderBy models.SearchEmailOrderBy orderBy models.SearchEmailOrderBy
) )
ctx.Data["SortType"] = ctx.Form("sort") ctx.Data["SortType"] = ctx.FormString("sort")
switch ctx.Form("sort") { switch ctx.FormString("sort") {
case "email": case "email":
orderBy = models.SearchEmailOrderByEmail orderBy = models.SearchEmailOrderByEmail
case "reverseemail": case "reverseemail":
@ -68,10 +68,10 @@ func Emails(ctx *context.Context) {
opts.Keyword = ctx.FormTrim("q") opts.Keyword = ctx.FormTrim("q")
opts.SortType = orderBy opts.SortType = orderBy
if len(ctx.Form("is_activated")) != 0 { if len(ctx.FormString("is_activated")) != 0 {
opts.IsActivated = util.OptionalBoolOf(ctx.FormBool("activated")) 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")) opts.IsPrimary = util.OptionalBoolOf(ctx.FormBool("primary"))
} }
@ -114,9 +114,9 @@ func ActivateEmail(ctx *context.Context) {
truefalse := map[string]bool{"1": true, "0": false} truefalse := map[string]bool{"1": true, "0": false}
uid := ctx.FormInt64("uid") uid := ctx.FormInt64("uid")
email := ctx.Form("email") email := ctx.FormString("email")
primary, okp := truefalse[ctx.Form("primary")] primary, okp := truefalse[ctx.FormString("primary")]
activate, oka := truefalse[ctx.Form("activate")] activate, oka := truefalse[ctx.FormString("activate")]
if uid == 0 || len(email) == 0 || !okp || !oka { if uid == 0 || len(email) == 0 || !okp || !oka {
ctx.Error(http.StatusBadRequest) ctx.Error(http.StatusBadRequest)

View file

@ -59,7 +59,7 @@ func DeleteRepo(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success")) ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success"))
ctx.JSON(http.StatusOK, map[string]interface{}{ 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") doSearch := ctx.FormBool("search")
ctx.Data["search"] = doSearch ctx.Data["search"] = doSearch
q := ctx.Form("q") q := ctx.FormString("q")
if !doSearch { if !doSearch {
pager := context.NewPagination(0, opts.PageSize, opts.Page, 5) pager := context.NewPagination(0, opts.PageSize, opts.Page, 5)
@ -109,10 +109,10 @@ func UnadoptedRepos(ctx *context.Context) {
// AdoptOrDeleteRepository adopts or deletes a repository // AdoptOrDeleteRepository adopts or deletes a repository
func AdoptOrDeleteRepository(ctx *context.Context) { func AdoptOrDeleteRepository(ctx *context.Context) {
dir := ctx.Form("id") dir := ctx.FormString("id")
action := ctx.Form("action") action := ctx.FormString("action")
page := ctx.FormInt("page") page := ctx.FormInt("page")
q := ctx.Form("q") q := ctx.FormString("q")
dirSplit := strings.SplitN(dir, "/", 2) dirSplit := strings.SplitN(dir, "/", 2)
if len(dirSplit) != 2 { if len(dirSplit) != 2 {

View file

@ -33,14 +33,14 @@ func Code(ctx *context.Context) {
ctx.Data["PageIsExplore"] = true ctx.Data["PageIsExplore"] = true
ctx.Data["PageIsExploreCode"] = true ctx.Data["PageIsExploreCode"] = true
language := strings.TrimSpace(ctx.Form("l")) language := strings.TrimSpace(ctx.FormString("l"))
keyword := strings.TrimSpace(ctx.Form("q")) keyword := strings.TrimSpace(ctx.FormString("q"))
page := ctx.FormInt("page") page := ctx.FormInt("page")
if page <= 0 { if page <= 0 {
page = 1 page = 1
} }
queryType := strings.TrimSpace(ctx.Form("t")) queryType := strings.TrimSpace(ctx.FormString("t"))
isMatch := queryType == "match" isMatch := queryType == "match"
var ( var (

View file

@ -42,8 +42,8 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
orderBy models.SearchOrderBy orderBy models.SearchOrderBy
) )
ctx.Data["SortType"] = ctx.Form("sort") ctx.Data["SortType"] = ctx.FormString("sort")
switch ctx.Form("sort") { switch ctx.FormString("sort") {
case "newest": case "newest":
orderBy = models.SearchOrderByNewest orderBy = models.SearchOrderByNewest
case "oldest": case "oldest":
@ -73,7 +73,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
orderBy = models.SearchOrderByRecentUpdated orderBy = models.SearchOrderByRecentUpdated
} }
keyword := strings.Trim(ctx.Form("q"), " ") keyword := strings.Trim(ctx.FormString("q"), " ")
topicOnly := ctx.FormBool("topic") topicOnly := ctx.FormBool("topic")
ctx.Data["TopicOnly"] = topicOnly ctx.Data["TopicOnly"] = topicOnly

View file

@ -44,8 +44,8 @@ func RenderUserSearch(ctx *context.Context, opts *models.SearchUserOptions, tplN
orderBy models.SearchOrderBy orderBy models.SearchOrderBy
) )
ctx.Data["SortType"] = ctx.Form("sort") ctx.Data["SortType"] = ctx.FormString("sort")
switch ctx.Form("sort") { switch ctx.FormString("sort") {
case "newest": case "newest":
orderBy = models.SearchOrderByIDReverse orderBy = models.SearchOrderByIDReverse
case "oldest": case "oldest":
@ -63,7 +63,7 @@ func RenderUserSearch(ctx *context.Context, opts *models.SearchUserOptions, tplN
orderBy = models.SearchOrderByAlphabetically orderBy = models.SearchOrderByAlphabetically
} }
opts.Keyword = strings.Trim(ctx.Form("q"), " ") opts.Keyword = strings.Trim(ctx.FormString("q"), " ")
opts.OrderBy = orderBy opts.OrderBy = orderBy
if len(opts.Keyword) == 0 || isKeywordValid(opts.Keyword) { if len(opts.Keyword) == 0 || isKeywordValid(opts.Keyword) {
users, count, err = models.SearchUsers(opts) users, count, err = models.SearchUsers(opts)

View file

@ -18,7 +18,7 @@ import (
) )
func goGet(ctx *context.Context) { 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 return
} }

View file

@ -51,8 +51,8 @@ func Home(ctx *context.Context) {
} }
var orderBy models.SearchOrderBy var orderBy models.SearchOrderBy
ctx.Data["SortType"] = ctx.Form("sort") ctx.Data["SortType"] = ctx.FormString("sort")
switch ctx.Form("sort") { switch ctx.FormString("sort") {
case "newest": case "newest":
orderBy = models.SearchOrderByNewest orderBy = models.SearchOrderByNewest
case "oldest": case "oldest":
@ -78,7 +78,7 @@ func Home(ctx *context.Context) {
orderBy = models.SearchOrderByRecentUpdated orderBy = models.SearchOrderByRecentUpdated
} }
keyword := strings.Trim(ctx.Form("q"), " ") keyword := strings.Trim(ctx.FormString("q"), " ")
ctx.Data["Keyword"] = keyword ctx.Data["Keyword"] = keyword
page := ctx.FormInt("page") page := ctx.FormInt("page")

View file

@ -15,7 +15,7 @@ import (
// RetrieveLabels find all the labels of an organization // RetrieveLabels find all the labels of an organization
func RetrieveLabels(ctx *context.Context) { 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 { if err != nil {
ctx.ServerError("RetrieveLabels.GetLabels", err) ctx.ServerError("RetrieveLabels.GetLabels", err)
return return
@ -25,7 +25,7 @@ func RetrieveLabels(ctx *context.Context) {
} }
ctx.Data["Labels"] = labels ctx.Data["Labels"] = labels
ctx.Data["NumLabels"] = len(labels) ctx.Data["NumLabels"] = len(labels)
ctx.Data["SortType"] = ctx.Form("sort") ctx.Data["SortType"] = ctx.FormString("sort")
} }
// NewLabel create new label for organization // NewLabel create new label for organization

View file

@ -155,7 +155,7 @@ func SettingsDelete(ctx *context.Context) {
org := ctx.Org.Organization org := ctx.Org.Organization
if ctx.Req.Method == "POST" { 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.Data["Err_OrgName"] = true
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_org_name"), tplSettingsDelete, nil) ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_org_name"), tplSettingsDelete, nil)
return return

View file

@ -55,7 +55,7 @@ func TeamsAction(ctx *context.Context) {
return return
} }
page := ctx.Form("page") page := ctx.FormString("page")
var err error var err error
switch ctx.Params(":action") { switch ctx.Params(":action") {
case "join": case "join":
@ -78,7 +78,7 @@ func TeamsAction(ctx *context.Context) {
ctx.Error(http.StatusNotFound) ctx.Error(http.StatusNotFound)
return return
} }
uname := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Form("uname"))) uname := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("uname")))
var u *models.User var u *models.User
u, err = models.GetUserByName(uname) u, err = models.GetUserByName(uname)
if err != nil { if err != nil {
@ -140,7 +140,7 @@ func TeamsRepoAction(ctx *context.Context) {
action := ctx.Params(":action") action := ctx.Params(":action")
switch action { switch action {
case "add": case "add":
repoName := path.Base(ctx.Form("repo_name")) repoName := path.Base(ctx.FormString("repo_name"))
var repo *models.Repository var repo *models.Repository
repo, err = models.GetRepositoryByName(ctx.Org.Organization.ID, repoName) repo, err = models.GetRepositoryByName(ctx.Org.Organization.ID, repoName)
if err != nil { if err != nil {

View file

@ -71,7 +71,7 @@ func uploadAttachment(ctx *context.Context, allowedTypes string) {
// DeleteAttachment response for deleting issue's attachment // DeleteAttachment response for deleting issue's attachment
func DeleteAttachment(ctx *context.Context) { func DeleteAttachment(ctx *context.Context) {
file := ctx.Form("file") file := ctx.FormString("file")
attach, err := models.GetAttachmentByUUID(file) attach, err := models.GetAttachmentByUUID(file)
if err != nil { if err != nil {
ctx.Error(http.StatusBadRequest, err.Error()) ctx.Error(http.StatusBadRequest, err.Error())

View file

@ -84,7 +84,7 @@ func Branches(ctx *context.Context) {
// DeleteBranchPost responses for delete merged branch // DeleteBranchPost responses for delete merged branch
func DeleteBranchPost(ctx *context.Context) { func DeleteBranchPost(ctx *context.Context) {
defer redirect(ctx) 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 { if err := repo_service.DeleteBranch(ctx.User, ctx.Repo.Repository, ctx.Repo.GitRepo, branchName); err != nil {
switch { switch {
@ -113,7 +113,7 @@ func RestoreBranchPost(ctx *context.Context) {
defer redirect(ctx) defer redirect(ctx)
branchID := ctx.FormInt64("branch_id") branchID := ctx.FormInt64("branch_id")
branchName := ctx.Form("name") branchName := ctx.FormString("name")
deletedBranch, err := ctx.Repo.Repository.GetDeletedBranchByID(branchID) deletedBranch, err := ctx.Repo.Repository.GetDeletedBranchByID(branchID)
if err != nil { if err != nil {

View file

@ -177,7 +177,7 @@ func SearchCommits(ctx *context.Context) {
ctx.Data["PageIsCommits"] = true ctx.Data["PageIsCommits"] = true
ctx.Data["PageIsViewCode"] = true ctx.Data["PageIsViewCode"] = true
query := strings.Trim(ctx.Form("q"), " ") query := strings.Trim(ctx.FormString("q"), " ")
if len(query) == 0 { if len(query) == 0 {
ctx.Redirect(ctx.Repo.RepoLink + "/commits/" + ctx.Repo.BranchNameSubURL()) ctx.Redirect(ctx.Repo.RepoLink + "/commits/" + ctx.Repo.BranchNameSubURL())
return return

View file

@ -700,9 +700,9 @@ func ExcerptBlob(ctx *context.Context) {
idxRight := ctx.FormInt("right") idxRight := ctx.FormInt("right")
leftHunkSize := ctx.FormInt("left_hunk_size") leftHunkSize := ctx.FormInt("left_hunk_size")
rightHunkSize := ctx.FormInt("right_hunk_size") rightHunkSize := ctx.FormInt("right_hunk_size")
anchor := ctx.Form("anchor") anchor := ctx.FormString("anchor")
direction := ctx.Form("direction") direction := ctx.FormString("direction")
filePath := ctx.Form("path") filePath := ctx.FormString("path")
gitRepo := ctx.Repo.GitRepo gitRepo := ctx.Repo.GitRepo
chunkSize := gitdiff.BlobExcerptChunkSize chunkSize := gitdiff.BlobExcerptChunkSize
commit, err := gitRepo.GetCommit(commitID) commit, err := gitRepo.GetCommit(commitID)

View file

@ -70,13 +70,13 @@ func httpBase(ctx *context.Context) (h *serviceHandler) {
username := ctx.Params(":username") username := ctx.Params(":username")
reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git") reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git")
if ctx.Form("go-get") == "1" { if ctx.FormString("go-get") == "1" {
context.EarlyResponseForGoGetMeta(ctx) context.EarlyResponseForGoGetMeta(ctx)
return return
} }
var isPull, receivePack bool var isPull, receivePack bool
service := ctx.Form("service") service := ctx.FormString("service")
if service == "git-receive-pack" || if service == "git-receive-pack" ||
strings.HasSuffix(ctx.Req.URL.Path, "git-receive-pack") { strings.HasSuffix(ctx.Req.URL.Path, "git-receive-pack") {
isPull = false isPull = false

View file

@ -110,8 +110,8 @@ func MustAllowPulls(ctx *context.Context) {
func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption util.OptionalBool) { func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption util.OptionalBool) {
var err error var err error
viewType := ctx.Form("type") viewType := ctx.FormString("type")
sortType := ctx.Form("sort") sortType := ctx.FormString("sort")
types := []string{"all", "your_repositories", "assigned", "created_by", "mentioned", "review_requested"} types := []string{"all", "your_repositories", "assigned", "created_by", "mentioned", "review_requested"}
if !util.IsStringInSlice(viewType, types, true) { if !util.IsStringInSlice(viewType, types, true) {
viewType = "all" viewType = "all"
@ -140,7 +140,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
repo := ctx.Repo.Repository repo := ctx.Repo.Repository
var labelIDs []int64 var labelIDs []int64
selectLabels := ctx.Form("labels") selectLabels := ctx.FormString("labels")
if len(selectLabels) > 0 && selectLabels != "0" { if len(selectLabels) > 0 && selectLabels != "0" {
labelIDs, err = base.StringsToInt64s(strings.Split(selectLabels, ",")) labelIDs, err = base.StringsToInt64s(strings.Split(selectLabels, ","))
if err != nil { 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}) { if bytes.Contains([]byte(keyword), []byte{0x00}) {
keyword = "" 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 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 isShowClosed = true
} }
@ -285,7 +285,7 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption uti
} }
if repo.Owner.IsOrganization() { 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 { if err != nil {
ctx.ServerError("GetLabelsByOrgID", err) ctx.ServerError("GetLabelsByOrgID", err)
return return
@ -380,7 +380,7 @@ func Issues(ctx *context.Context) {
// Get milestones // Get milestones
ctx.Data["Milestones"], err = models.GetMilestones(models.GetMilestonesOption{ ctx.Data["Milestones"], err = models.GetMilestones(models.GetMilestonesOption{
RepoID: ctx.Repo.Repository.ID, RepoID: ctx.Repo.Repository.ID,
State: api.StateType(ctx.Form("state")), State: api.StateType(ctx.FormString("state")),
}) })
if err != nil { if err != nil {
ctx.ServerError("GetAllRepoMilestones", err) ctx.ServerError("GetAllRepoMilestones", err)
@ -655,7 +655,7 @@ func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository, isPull boo
} }
ctx.Data["Labels"] = labels ctx.Data["Labels"] = labels
if repo.Owner.IsOrganization() { 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 { if err != nil {
return 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) { func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleDirs []string, possibleFiles []string) {
templateCandidates := make([]string, 0, len(possibleFiles)) templateCandidates := make([]string, 0, len(possibleFiles))
if ctx.Form("template") != "" { if ctx.FormString("template") != "" {
for _, dirName := range possibleDirs { 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 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 { if repoLabels, err := models.GetLabelsByRepoID(ctx.Repo.Repository.ID, "", models.ListOptions{}); err == nil {
ctx.Data["Labels"] = repoLabels ctx.Data["Labels"] = repoLabels
if ctx.Repo.Owner.IsOrganization() { 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 ctx.Data["OrgLabels"] = orgLabels
repoLabels = append(repoLabels, orgLabels...) repoLabels = append(repoLabels, orgLabels...)
} }
@ -773,9 +773,9 @@ func NewIssue(ctx *context.Context) {
ctx.Data["RequireSimpleMDE"] = true ctx.Data["RequireSimpleMDE"] = true
ctx.Data["RequireTribute"] = true ctx.Data["RequireTribute"] = true
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
title := ctx.Form("title") title := ctx.FormString("title")
ctx.Data["TitleQuery"] = title ctx.Data["TitleQuery"] = title
body := ctx.Form("body") body := ctx.FormString("body")
ctx.Data["BodyQuery"] = body ctx.Data["BodyQuery"] = body
ctx.Data["IsProjectsEnabled"] = ctx.Repo.CanRead(models.UnitTypeProjects) ctx.Data["IsProjectsEnabled"] = ctx.Repo.CanRead(models.UnitTypeProjects)
@ -1174,7 +1174,7 @@ func ViewIssue(ctx *context.Context) {
ctx.Data["Labels"] = labels ctx.Data["Labels"] = labels
if repo.Owner.IsOrganization() { 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 { if err != nil {
ctx.ServerError("GetLabelsByOrgID", err) ctx.ServerError("GetLabelsByOrgID", err)
return return
@ -1624,7 +1624,7 @@ func checkIssueRights(ctx *context.Context, issue *models.Issue) {
} }
func getActionIssues(ctx *context.Context) []*models.Issue { func getActionIssues(ctx *context.Context) []*models.Issue {
commaSeparatedIssueIDs := ctx.Form("issue_ids") commaSeparatedIssueIDs := ctx.FormString("issue_ids")
if len(commaSeparatedIssueIDs) == 0 { if len(commaSeparatedIssueIDs) == 0 {
return nil return nil
} }
@ -1722,7 +1722,7 @@ func UpdateIssueContent(ctx *context.Context) {
return return
} }
content := ctx.Form("content") content := ctx.FormString("content")
if err := issue_service.ChangeContent(issue, ctx.User, content); err != nil { if err := issue_service.ChangeContent(issue, ctx.User, content); err != nil {
ctx.ServerError("ChangeContent", err) ctx.ServerError("ChangeContent", err)
return return
@ -1735,7 +1735,7 @@ func UpdateIssueContent(ctx *context.Context) {
} }
content, err := markdown.RenderString(&markup.RenderContext{ content, err := markdown.RenderString(&markup.RenderContext{
URLPrefix: ctx.Form("context"), URLPrefix: ctx.FormString("context"),
Metas: ctx.Repo.Repository.ComposeMetas(), Metas: ctx.Repo.Repository.ComposeMetas(),
GitRepo: ctx.Repo.GitRepo, GitRepo: ctx.Repo.GitRepo,
}, issue.Content) }, issue.Content)
@ -1783,7 +1783,7 @@ func UpdateIssueAssignee(ctx *context.Context) {
} }
assigneeID := ctx.FormInt64("id") assigneeID := ctx.FormInt64("id")
action := ctx.Form("action") action := ctx.FormString("action")
for _, issue := range issues { for _, issue := range issues {
switch action { switch action {
@ -1829,7 +1829,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
} }
reviewID := ctx.FormInt64("id") reviewID := ctx.FormInt64("id")
action := ctx.Form("action") action := ctx.FormString("action")
// TODO: Not support 'clear' now // TODO: Not support 'clear' now
if action != "attach" && action != "detach" { if action != "attach" && action != "detach" {
@ -1954,7 +1954,7 @@ func UpdateIssueStatus(ctx *context.Context) {
} }
var isClosed bool var isClosed bool
switch action := ctx.Form("action"); action { switch action := ctx.FormString("action"); action {
case "open": case "open":
isClosed = false isClosed = false
case "close": case "close":
@ -2145,7 +2145,7 @@ func UpdateCommentContent(ctx *context.Context) {
} }
oldContent := comment.Content oldContent := comment.Content
comment.Content = ctx.Form("content") comment.Content = ctx.FormString("content")
if len(comment.Content) == 0 { if len(comment.Content) == 0 {
ctx.JSON(http.StatusOK, map[string]interface{}{ ctx.JSON(http.StatusOK, map[string]interface{}{
"content": "", "content": "",
@ -2164,7 +2164,7 @@ func UpdateCommentContent(ctx *context.Context) {
} }
content, err := markdown.RenderString(&markup.RenderContext{ content, err := markdown.RenderString(&markup.RenderContext{
URLPrefix: ctx.Form("context"), URLPrefix: ctx.FormString("context"),
Metas: ctx.Repo.Repository.ComposeMetas(), Metas: ctx.Repo.Repository.ComposeMetas(),
GitRepo: ctx.Repo.GitRepo, GitRepo: ctx.Repo.GitRepo,
}, comment.Content) }, comment.Content)

View file

@ -53,7 +53,7 @@ func InitializeLabels(ctx *context.Context) {
// RetrieveLabels find all the labels of a repository and organization // RetrieveLabels find all the labels of a repository and organization
func RetrieveLabels(ctx *context.Context) { 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 { if err != nil {
ctx.ServerError("RetrieveLabels.GetLabels", err) ctx.ServerError("RetrieveLabels.GetLabels", err)
return return
@ -66,7 +66,7 @@ func RetrieveLabels(ctx *context.Context) {
ctx.Data["Labels"] = labels ctx.Data["Labels"] = labels
if ctx.Repo.Owner.IsOrganization() { 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 { if err != nil {
ctx.ServerError("GetLabelsByOrgID", err) ctx.ServerError("GetLabelsByOrgID", err)
return return
@ -93,7 +93,7 @@ func RetrieveLabels(ctx *context.Context) {
} }
} }
ctx.Data["NumLabels"] = len(labels) ctx.Data["NumLabels"] = len(labels)
ctx.Data["SortType"] = ctx.Form("sort") ctx.Data["SortType"] = ctx.FormString("sort")
} }
// NewLabel create new label for repository // NewLabel create new label for repository
@ -165,7 +165,7 @@ func UpdateIssueLabel(ctx *context.Context) {
return return
} }
switch action := ctx.Form("action"); action { switch action := ctx.FormString("action"); action {
case "clear": case "clear":
for _, issue := range issues { for _, issue := range issues {
if err := issue_service.ClearLabels(issue, ctx.User); err != nil { if err := issue_service.ClearLabels(issue, ctx.User); err != nil {

View file

@ -195,7 +195,7 @@ func LFSLockFile(ctx *context.Context) {
ctx.NotFound("LFSLocks", nil) ctx.NotFound("LFSLocks", nil)
return return
} }
originalPath := ctx.Form("path") originalPath := ctx.FormString("path")
lockPath := originalPath lockPath := originalPath
if len(lockPath) == 0 { if len(lockPath) == 0 {
ctx.Flash.Error(ctx.Tr("repo.settings.lfs_invalid_locking_path", originalPath)) 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) ctx.NotFound("LFSFind", nil)
return return
} }
oid := ctx.Form("oid") oid := ctx.FormString("oid")
size := ctx.FormInt64("size") size := ctx.FormInt64("size")
if len(oid) == 0 || size == 0 { if len(oid) == 0 || size == 0 {
ctx.NotFound("LFSFind", nil) ctx.NotFound("LFSFind", nil)
return return
} }
sha := ctx.Form("sha") sha := ctx.FormString("sha")
ctx.Data["Title"] = oid ctx.Data["Title"] = oid
ctx.Data["PageIsSettingsLFS"] = true ctx.Data["PageIsSettingsLFS"] = true
var hash git.SHA1 var hash git.SHA1

View file

@ -34,7 +34,7 @@ func SetEditorconfigIfExists(ctx *context.Context) {
// SetDiffViewStyle set diff style as render variable // SetDiffViewStyle set diff style as render variable
func SetDiffViewStyle(ctx *context.Context) { func SetDiffViewStyle(ctx *context.Context) {
queryStyle := ctx.Form("style") queryStyle := ctx.FormString("style")
if !ctx.IsSigned { if !ctx.IsSigned {
ctx.Data["IsSplitStyle"] = queryStyle == "split" ctx.Data["IsSplitStyle"] = queryStyle == "split"
@ -62,7 +62,7 @@ func SetDiffViewStyle(ctx *context.Context) {
// SetWhitespaceBehavior set whitespace behavior as render variable // SetWhitespaceBehavior set whitespace behavior as render variable
func SetWhitespaceBehavior(ctx *context.Context) { func SetWhitespaceBehavior(ctx *context.Context) {
whitespaceBehavior := ctx.Form("whitespace") whitespaceBehavior := ctx.FormString("whitespace")
switch whitespaceBehavior { switch whitespaceBehavior {
case "ignore-all", "ignore-eol", "ignore-change": case "ignore-all", "ignore-eol", "ignore-change":
ctx.Data["WhitespaceBehavior"] = whitespaceBehavior ctx.Data["WhitespaceBehavior"] = whitespaceBehavior

View file

@ -39,22 +39,22 @@ func Migrate(ctx *context.Context) {
setMigrationContextData(ctx, serviceType) setMigrationContextData(ctx, serviceType)
if serviceType == 0 { if serviceType == 0 {
ctx.Data["Org"] = ctx.Form("org") ctx.Data["Org"] = ctx.FormString("org")
ctx.Data["Mirror"] = ctx.Form("mirror") ctx.Data["Mirror"] = ctx.FormString("mirror")
ctx.HTML(http.StatusOK, tplMigrate) ctx.HTML(http.StatusOK, tplMigrate)
return return
} }
ctx.Data["private"] = getRepoPrivate(ctx) ctx.Data["private"] = getRepoPrivate(ctx)
ctx.Data["mirror"] = ctx.Form("mirror") == "1" ctx.Data["mirror"] = ctx.FormString("mirror") == "1"
ctx.Data["lfs"] = ctx.Form("lfs") == "1" ctx.Data["lfs"] = ctx.FormString("lfs") == "1"
ctx.Data["wiki"] = ctx.Form("wiki") == "1" ctx.Data["wiki"] = ctx.FormString("wiki") == "1"
ctx.Data["milestones"] = ctx.Form("milestones") == "1" ctx.Data["milestones"] = ctx.FormString("milestones") == "1"
ctx.Data["labels"] = ctx.Form("labels") == "1" ctx.Data["labels"] = ctx.FormString("labels") == "1"
ctx.Data["issues"] = ctx.Form("issues") == "1" ctx.Data["issues"] = ctx.FormString("issues") == "1"
ctx.Data["pull_requests"] = ctx.Form("pull_requests") == "1" ctx.Data["pull_requests"] = ctx.FormString("pull_requests") == "1"
ctx.Data["releases"] = ctx.Form("releases") == "1" ctx.Data["releases"] = ctx.FormString("releases") == "1"
ctxUser := checkContextUser(ctx, ctx.FormInt64("org")) ctxUser := checkContextUser(ctx, ctx.FormInt64("org"))
if ctx.Written() { if ctx.Written() {

View file

@ -36,7 +36,7 @@ func Milestones(ctx *context.Context) {
ctx.Data["PageIsIssueList"] = true ctx.Data["PageIsIssueList"] = true
ctx.Data["PageIsMilestones"] = 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})) stats, err := models.GetMilestonesStatsByRepoCond(builder.And(builder.Eq{"id": ctx.Repo.Repository.ID}))
if err != nil { if err != nil {
ctx.ServerError("MilestoneStats", err) ctx.ServerError("MilestoneStats", err)
@ -45,9 +45,9 @@ func Milestones(ctx *context.Context) {
ctx.Data["OpenCount"] = stats.OpenCount ctx.Data["OpenCount"] = stats.OpenCount
ctx.Data["ClosedCount"] = stats.ClosedCount 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") page := ctx.FormInt("page")
if page <= 1 { if page <= 1 {

View file

@ -1129,8 +1129,8 @@ func CompareAndPullRequestPost(ctx *context.Context) {
// TriggerTask response for a trigger task request // TriggerTask response for a trigger task request
func TriggerTask(ctx *context.Context) { func TriggerTask(ctx *context.Context) {
pusherID := ctx.FormInt64("pusher") pusherID := ctx.FormInt64("pusher")
branch := ctx.Form("branch") branch := ctx.FormString("branch")
secret := ctx.Form("secret") secret := ctx.FormString("secret")
if len(branch) == 0 || len(secret) == 0 || pusherID <= 0 { if len(branch) == 0 || len(secret) == 0 || pusherID <= 0 {
ctx.Error(http.StatusNotFound) ctx.Error(http.StatusNotFound)
log.Trace("TriggerTask: branch or secret is empty, or pusher ID is not valid") log.Trace("TriggerTask: branch or secret is empty, or pusher ID is not valid")

View file

@ -101,8 +101,8 @@ func CreateCodeComment(ctx *context.Context) {
// UpdateResolveConversation add or remove an Conversation resolved mark // UpdateResolveConversation add or remove an Conversation resolved mark
func UpdateResolveConversation(ctx *context.Context) { func UpdateResolveConversation(ctx *context.Context) {
origin := ctx.Form("origin") origin := ctx.FormString("origin")
action := ctx.Form("action") action := ctx.FormString("action")
commentID := ctx.FormInt64("comment_id") commentID := ctx.FormInt64("comment_id")
comment, err := models.GetCommentByID(commentID) comment, err := models.GetCommentByID(commentID)

View file

@ -252,7 +252,7 @@ func NewRelease(ctx *context.Context) {
ctx.Data["RequireSimpleMDE"] = true ctx.Data["RequireSimpleMDE"] = true
ctx.Data["RequireTribute"] = true ctx.Data["RequireTribute"] = true
ctx.Data["tag_target"] = ctx.Repo.Repository.DefaultBranch 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) rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName)
if err != nil && !models.IsErrReleaseNotExist(err) { if err != nil && !models.IsErrReleaseNotExist(err) {
ctx.ServerError("GetRelease", err) ctx.ServerError("GetRelease", err)

View file

@ -291,8 +291,8 @@ func Action(ctx *context.Context) {
return return
} }
ctx.Repo.Repository.Description = ctx.Form("desc") ctx.Repo.Repository.Description = ctx.FormString("desc")
ctx.Repo.Repository.Website = ctx.Form("site") ctx.Repo.Repository.Website = ctx.FormString("site")
err = models.UpdateRepository(ctx.Repo.Repository, false) err = models.UpdateRepository(ctx.Repo.Repository, false)
} }
@ -301,7 +301,7 @@ func Action(ctx *context.Context) {
return 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 { func acceptOrRejectRepoTransfer(ctx *context.Context, accept bool) error {

View file

@ -22,13 +22,13 @@ func Search(ctx *context.Context) {
ctx.Redirect(ctx.Repo.RepoLink, 302) ctx.Redirect(ctx.Repo.RepoLink, 302)
return return
} }
language := strings.TrimSpace(ctx.Form("l")) language := strings.TrimSpace(ctx.FormString("l"))
keyword := strings.TrimSpace(ctx.Form("q")) keyword := strings.TrimSpace(ctx.FormString("q"))
page := ctx.FormInt("page") page := ctx.FormInt("page")
if page <= 0 { if page <= 0 {
page = 1 page = 1
} }
queryType := strings.TrimSpace(ctx.Form("t")) queryType := strings.TrimSpace(ctx.FormString("t"))
isMatch := queryType == "match" isMatch := queryType == "match"
total, searchResults, searchResultLanguages, err := code_indexer.PerformSearch([]int64{ctx.Repo.Repository.ID}, total, searchResults, searchResultLanguages, err := code_indexer.PerformSearch([]int64{ctx.Repo.Repository.ID},

View file

@ -70,7 +70,7 @@ func SettingsPost(ctx *context.Context) {
repo := ctx.Repo.Repository repo := ctx.Repo.Repository
switch ctx.Form("action") { switch ctx.FormString("action") {
case "update": case "update":
if ctx.HasError() { if ctx.HasError() {
ctx.HTML(http.StatusOK, tplSettingsOptions) ctx.HTML(http.StatusOK, tplSettingsOptions)
@ -560,7 +560,7 @@ func SettingsPost(ctx *context.Context) {
return return
} }
newOwner, err := models.GetUserByName(ctx.Form("new_owner_name")) newOwner, err := models.GetUserByName(ctx.FormString("new_owner_name"))
if err != nil { if err != nil {
if models.IsErrUserNotExist(err) { if models.IsErrUserNotExist(err) {
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_owner_name"), tplSettingsOptions, nil) 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 // CollaborationPost response for actions for a collaboration of a repository
func CollaborationPost(ctx *context.Context) { 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 { if len(name) == 0 || ctx.Repo.Owner.LowerName == name {
ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path) ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path)
return return
@ -854,7 +854,7 @@ func AddTeamPost(ctx *context.Context) {
return return
} }
name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Form("team"))) name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("team")))
if len(name) == 0 { if len(name) == 0 {
ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration")
return return
@ -988,7 +988,7 @@ func GitHooksEditPost(ctx *context.Context) {
} }
return return
} }
hook.Content = ctx.Form("content") hook.Content = ctx.FormString("content")
if err = hook.Update(); err != nil { if err = hook.Update(); err != nil {
ctx.ServerError("hook.Update", err) ctx.ServerError("hook.Update", err)
return return

View file

@ -60,14 +60,14 @@ func ProtectedBranchPost(ctx *context.Context) {
repo := ctx.Repo.Repository repo := ctx.Repo.Repository
switch ctx.Form("action") { switch ctx.FormString("action") {
case "default_branch": case "default_branch":
if ctx.HasError() { if ctx.HasError() {
ctx.HTML(http.StatusOK, tplBranches) ctx.HTML(http.StatusOK, tplBranches)
return return
} }
branch := ctx.Form("branch") branch := ctx.FormString("branch")
if !ctx.Repo.GitRepo.IsBranchExist(branch) { if !ctx.Repo.GitRepo.IsBranchExist(branch) {
ctx.Status(404) ctx.Status(404)
return return

View file

@ -23,7 +23,7 @@ func TopicsPost(ctx *context.Context) {
} }
var topics = make([]string, 0) var topics = make([]string, 0)
var topicsStr = strings.TrimSpace(ctx.Form("topics")) var topicsStr = strings.TrimSpace(ctx.FormString("topics"))
if len(topicsStr) > 0 { if len(topicsStr) > 0 {
topics = strings.Split(topicsStr, ",") topics = strings.Split(topicsStr, ",")
} }

View file

@ -416,7 +416,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
isTextFile := st.IsText() isTextFile := st.IsText()
isLFSFile := false isLFSFile := false
isDisplayingSource := ctx.Form("display") == "source" isDisplayingSource := ctx.FormString("display") == "source"
isDisplayingRendered := !isDisplayingSource isDisplayingRendered := !isDisplayingSource
//Check for LFS meta file //Check for LFS meta file

View file

@ -111,7 +111,7 @@ func checkAutoLogin(ctx *context.Context) bool {
return true return true
} }
redirectTo := ctx.Form("redirect_to") redirectTo := ctx.FormString("redirect_to")
if len(redirectTo) > 0 { if len(redirectTo) > 0 {
middleware.SetRedirectToCookie(ctx.Resp, redirectTo) middleware.SetRedirectToCookie(ctx.Resp, redirectTo)
} else { } else {
@ -1333,7 +1333,7 @@ func handleUserCreated(ctx *context.Context, u *models.User, gothUser *goth.User
// Activate render activate user page // Activate render activate user page
func Activate(ctx *context.Context) { func Activate(ctx *context.Context) {
code := ctx.Form("code") code := ctx.FormString("code")
if len(code) == 0 { if len(code) == 0 {
ctx.Data["IsActivatePage"] = true ctx.Data["IsActivatePage"] = true
@ -1381,7 +1381,7 @@ func Activate(ctx *context.Context) {
// ActivatePost handles account activation with password check // ActivatePost handles account activation with password check
func ActivatePost(ctx *context.Context) { func ActivatePost(ctx *context.Context) {
code := ctx.Form("code") code := ctx.FormString("code")
if len(code) == 0 { if len(code) == 0 {
ctx.Redirect(setting.AppSubURL + "/user/activate") ctx.Redirect(setting.AppSubURL + "/user/activate")
return return
@ -1397,7 +1397,7 @@ func ActivatePost(ctx *context.Context) {
// if account is local account, verify password // if account is local account, verify password
if user.LoginSource == 0 { if user.LoginSource == 0 {
password := ctx.Form("password") password := ctx.FormString("password")
if len(password) == 0 { if len(password) == 0 {
ctx.Data["Code"] = code ctx.Data["Code"] = code
ctx.Data["NeedsPassword"] = true ctx.Data["NeedsPassword"] = true
@ -1454,8 +1454,8 @@ func handleAccountActivation(ctx *context.Context, user *models.User) {
// ActivateEmail render the activate email page // ActivateEmail render the activate email page
func ActivateEmail(ctx *context.Context) { func ActivateEmail(ctx *context.Context) {
code := ctx.Form("code") code := ctx.FormString("code")
emailStr := ctx.Form("email") emailStr := ctx.FormString("email")
// Verify code. // Verify code.
if email := models.VerifyActiveEmailCode(code, emailStr); email != nil { if email := models.VerifyActiveEmailCode(code, emailStr); email != nil {
@ -1491,7 +1491,7 @@ func ForgotPasswd(ctx *context.Context) {
return return
} }
email := ctx.Form("email") email := ctx.FormString("email")
ctx.Data["Email"] = email ctx.Data["Email"] = email
ctx.Data["IsResetRequest"] = true ctx.Data["IsResetRequest"] = true
@ -1508,7 +1508,7 @@ func ForgotPasswdPost(ctx *context.Context) {
} }
ctx.Data["IsResetRequest"] = true ctx.Data["IsResetRequest"] = true
email := ctx.Form("email") email := ctx.FormString("email")
ctx.Data["Email"] = email ctx.Data["Email"] = email
u, err := models.GetUserByEmail(email) u, err := models.GetUserByEmail(email)
@ -1548,7 +1548,7 @@ func ForgotPasswdPost(ctx *context.Context) {
} }
func commonResetPassword(ctx *context.Context) (*models.User, *models.TwoFactor) { 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["Title"] = ctx.Tr("auth.reset_password")
ctx.Data["Code"] = code ctx.Data["Code"] = code
@ -1617,7 +1617,7 @@ func ResetPasswdPost(ctx *context.Context) {
} }
// Validate password length. // Validate password length.
passwd := ctx.Form("password") passwd := ctx.FormString("password")
if len(passwd) < setting.MinPasswordLength { if len(passwd) < setting.MinPasswordLength {
ctx.Data["IsResetForm"] = true ctx.Data["IsResetForm"] = true
ctx.Data["Err_Password"] = true ctx.Data["Err_Password"] = true
@ -1644,7 +1644,7 @@ func ResetPasswdPost(ctx *context.Context) {
regenerateScratchToken := false regenerateScratchToken := false
if twofa != nil { if twofa != nil {
if ctx.FormBool("scratch_code") { if ctx.FormBool("scratch_code") {
if !twofa.VerifyScratchToken(ctx.Form("token")) { if !twofa.VerifyScratchToken(ctx.FormString("token")) {
ctx.Data["IsResetForm"] = true ctx.Data["IsResetForm"] = true
ctx.Data["Err_Token"] = true ctx.Data["Err_Token"] = true
ctx.RenderWithErr(ctx.Tr("auth.twofa_scratch_token_incorrect"), tplResetPassword, nil) ctx.RenderWithErr(ctx.Tr("auth.twofa_scratch_token_incorrect"), tplResetPassword, nil)
@ -1652,7 +1652,7 @@ func ResetPasswdPost(ctx *context.Context) {
} }
regenerateScratchToken = true regenerateScratchToken = true
} else { } else {
passcode := ctx.Form("passcode") passcode := ctx.FormString("passcode")
ok, err := twofa.ValidateTOTP(passcode) ok, err := twofa.ValidateTOTP(passcode)
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, "ValidateTOTP", err.Error()) ctx.Error(http.StatusInternalServerError, "ValidateTOTP", err.Error())
@ -1689,7 +1689,7 @@ func ResetPasswdPost(ctx *context.Context) {
log.Trace("User password reset: %s", u.Name) log.Trace("User password reset: %s", u.Name)
ctx.Data["IsResetFailed"] = true ctx.Data["IsResetFailed"] = true
remember := len(ctx.Form("remember")) != 0 remember := len(ctx.FormString("remember")) != 0
if regenerateScratchToken { if regenerateScratchToken {
// Invalidate the scratch token. // Invalidate the scratch token.

View file

@ -34,7 +34,7 @@ const (
func SignInOpenID(ctx *context.Context) { func SignInOpenID(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("sign_in") ctx.Data["Title"] = ctx.Tr("sign_in")
if ctx.Form("openid.return_to") != "" { if ctx.FormString("openid.return_to") != "" {
signInOpenIDVerify(ctx) signInOpenIDVerify(ctx)
return return
} }
@ -46,7 +46,7 @@ func SignInOpenID(ctx *context.Context) {
return return
} }
redirectTo := ctx.Form("redirect_to") redirectTo := ctx.FormString("redirect_to")
if len(redirectTo) > 0 { if len(redirectTo) > 0 {
middleware.SetRedirectToCookie(ctx.Resp, redirectTo) middleware.SetRedirectToCookie(ctx.Resp, redirectTo)
} else { } else {

View file

@ -157,7 +157,7 @@ func Dashboard(ctx *context.Context) {
IncludePrivate: true, IncludePrivate: true,
OnlyPerformedBy: false, OnlyPerformedBy: false,
IncludeDeleted: false, IncludeDeleted: false,
Date: ctx.Form("date"), Date: ctx.FormString("date"),
}) })
if ctx.Written() { if ctx.Written() {
@ -200,11 +200,11 @@ func Milestones(ctx *context.Context) {
repoCond = userRepoCond repoCond = userRepoCond
repoIDs []int64 repoIDs []int64
reposQuery = ctx.Form("repos") reposQuery = ctx.FormString("repos")
isShowClosed = ctx.Form("state") == "closed" isShowClosed = ctx.FormString("state") == "closed"
sortType = ctx.Form("sort") sortType = ctx.FormString("sort")
page = ctx.FormInt("page") page = ctx.FormInt("page")
keyword = strings.Trim(ctx.Form("q"), " ") keyword = strings.Trim(ctx.FormString("q"), " ")
) )
if page <= 1 { if page <= 1 {
@ -380,7 +380,7 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
var ( var (
viewType string viewType string
sortType = ctx.Form("sort") sortType = ctx.FormString("sort")
filterMode = models.FilterModeAll 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. // - Remember pre-determined viewType string for later. Will be posted to ctx.Data.
// Organization does not have view type and filter mode. // Organization does not have view type and filter mode.
// User: // 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. // 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. // - Remember either this or a fallback. Will be posted to ctx.Data.
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
// TODO: distinguish during routing // TODO: distinguish during routing
viewType = ctx.Form("type") viewType = ctx.FormString("type")
switch viewType { switch viewType {
case "assigned": case "assigned":
filterMode = models.FilterModeAssign 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 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 ctx.Data["Keyword"] = keyword
// Execute keyword search for issues. // 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. // Educated guess: Do or don't show closed issues.
isShowClosed := ctx.Form("state") == "closed" isShowClosed := ctx.FormString("state") == "closed"
opts.IsClosed = util.OptionalBoolOf(isShowClosed) opts.IsClosed = util.OptionalBoolOf(isShowClosed)
// Filter repos and count issues in them. Count will be used later. // 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). // Get IDs for labels (a filter option for issues/pulls).
// Required for IssuesOptions. // Required for IssuesOptions.
var labelIDs []int64 var labelIDs []int64
selectedLabels := ctx.Form("labels") selectedLabels := ctx.FormString("labels")
if len(selectedLabels) > 0 && selectedLabels != "0" { if len(selectedLabels) > 0 && selectedLabels != "0" {
labelIDs, err = base.StringsToInt64s(strings.Split(selectedLabels, ",")) labelIDs, err = base.StringsToInt64s(strings.Split(selectedLabels, ","))
if err != nil { if err != nil {
@ -512,9 +512,9 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
} }
opts.LabelIDs = labelIDs 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. // Gets set when clicking filters on the issues overview page.
repoIDs := getRepoIDs(ctx.Form("repos")) repoIDs := getRepoIDs(ctx.FormString("repos"))
if len(repoIDs) > 0 { if len(repoIDs) > 0 {
opts.RepoIDs = repoIDs opts.RepoIDs = repoIDs
} }
@ -658,7 +658,7 @@ func buildIssueOverview(ctx *context.Context, unitType models.UnitType) {
ctx.Data["IsShowClosed"] = isShowClosed ctx.Data["IsShowClosed"] = isShowClosed
ctx.Data["IssueRefEndNames"], ctx.Data["IssueRefURLs"] = ctx.Data["IssueRefEndNames"], ctx.Data["IssueRefURLs"] =
issue_service.GetRefEndNamesAndURLs(issues, ctx.Form("RepoLink")) issue_service.GetRefEndNamesAndURLs(issues, ctx.FormString("RepoLink"))
ctx.Data["Issues"] = issues ctx.Data["Issues"] = issues
@ -900,7 +900,7 @@ func ShowGPGKeys(ctx *context.Context, uid int64) {
// Email2User show user page via email // Email2User show user page via email
func Email2User(ctx *context.Context) { func Email2User(ctx *context.Context) {
u, err := models.GetUserByEmail(ctx.Form("email")) u, err := models.GetUserByEmail(ctx.FormString("email"))
if err != nil { if err != nil {
if models.IsErrUserNotExist(err) { if models.IsErrUserNotExist(err) {
ctx.NotFound("GetUserByEmail", err) ctx.NotFound("GetUserByEmail", err)

View file

@ -50,7 +50,7 @@ func Notifications(c *context.Context) {
return return
} }
if c.FormBool("div-only") { if c.FormBool("div-only") {
c.Data["SequenceNumber"] = c.Form("sequence-number") c.Data["SequenceNumber"] = c.FormString("sequence-number")
c.HTML(http.StatusOK, tplNotificationDiv) c.HTML(http.StatusOK, tplNotificationDiv)
return return
} }
@ -59,7 +59,7 @@ func Notifications(c *context.Context) {
func getNotifications(c *context.Context) { func getNotifications(c *context.Context) {
var ( var (
keyword = strings.Trim(c.Form("q"), " ") keyword = strings.Trim(c.FormString("q"), " ")
status models.NotificationStatus status models.NotificationStatus
page = c.FormInt("page") page = c.FormInt("page")
perPage = c.FormInt("perPage") 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 // redirect to last page if request page is more than total pages
pager := context.NewPagination(int(total), perPage, page, 5) pager := context.NewPagination(int(total), perPage, page, 5)
if pager.Paginater.Current() < page { 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 return
} }
@ -167,7 +167,7 @@ func NotificationStatusPost(c *context.Context) {
} }
if !c.FormBool("noredirect") { 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) c.Redirect(url, http.StatusSeeOther)
} }

View file

@ -143,7 +143,7 @@ func Profile(ctx *context.Context) {
ctx.Data["Orgs"] = orgs ctx.Data["Orgs"] = orgs
ctx.Data["HasOrgsVisible"] = models.HasOrgsVisible(orgs, ctx.User) ctx.Data["HasOrgsVisible"] = models.HasOrgsVisible(orgs, ctx.User)
tab := ctx.Form("tab") tab := ctx.FormString("tab")
ctx.Data["TabName"] = tab ctx.Data["TabName"] = tab
page := ctx.FormInt("page") page := ctx.FormInt("page")
@ -160,8 +160,8 @@ func Profile(ctx *context.Context) {
orderBy models.SearchOrderBy orderBy models.SearchOrderBy
) )
ctx.Data["SortType"] = ctx.Form("sort") ctx.Data["SortType"] = ctx.FormString("sort")
switch ctx.Form("sort") { switch ctx.FormString("sort") {
case "newest": case "newest":
orderBy = models.SearchOrderByNewest orderBy = models.SearchOrderByNewest
case "oldest": case "oldest":
@ -187,7 +187,7 @@ func Profile(ctx *context.Context) {
orderBy = models.SearchOrderByRecentUpdated orderBy = models.SearchOrderByRecentUpdated
} }
keyword := strings.Trim(ctx.Form("q"), " ") keyword := strings.Trim(ctx.FormString("q"), " ")
ctx.Data["Keyword"] = keyword ctx.Data["Keyword"] = keyword
switch tab { switch tab {
case "followers": case "followers":
@ -220,7 +220,7 @@ func Profile(ctx *context.Context) {
IncludePrivate: showPrivate, IncludePrivate: showPrivate,
OnlyPerformedBy: true, OnlyPerformedBy: true,
IncludeDeleted: false, IncludeDeleted: false,
Date: ctx.Form("date"), Date: ctx.FormString("date"),
}) })
if ctx.Written() { if ctx.Written() {
return return
@ -332,5 +332,5 @@ func Action(ctx *context.Context) {
return return
} }
ctx.RedirectToFirst(ctx.Form("redirect_to"), u.HomeLink()) ctx.RedirectToFirst(ctx.FormString("redirect_to"), u.HomeLink())
} }

View file

@ -90,7 +90,7 @@ func EmailPost(ctx *context.Context) {
ctx.Data["PageIsSettingsAccount"] = true ctx.Data["PageIsSettingsAccount"] = true
// Make emailaddress primary. // 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 { if err := models.MakeEmailPrimary(&models.EmailAddress{ID: ctx.FormInt64("id")}); err != nil {
ctx.ServerError("MakeEmailPrimary", err) ctx.ServerError("MakeEmailPrimary", err)
return return
@ -101,7 +101,7 @@ func EmailPost(ctx *context.Context) {
return return
} }
// Send activation Email // Send activation Email
if ctx.Form("_method") == "SENDACTIVATION" { if ctx.FormString("_method") == "SENDACTIVATION" {
var address string var address string
if ctx.Cache.IsExist("MailResendLimit_" + ctx.User.LowerName) { if ctx.Cache.IsExist("MailResendLimit_" + ctx.User.LowerName) {
log.Error("Send activation: activation still pending") log.Error("Send activation: activation still pending")
@ -147,8 +147,8 @@ func EmailPost(ctx *context.Context) {
return return
} }
// Set Email Notification Preference // Set Email Notification Preference
if ctx.Form("_method") == "NOTIFICATION" { if ctx.FormString("_method") == "NOTIFICATION" {
preference := ctx.Form("preference") preference := ctx.FormString("preference")
if !(preference == models.EmailNotificationsEnabled || if !(preference == models.EmailNotificationsEnabled ||
preference == models.EmailNotificationsOnMention || preference == models.EmailNotificationsOnMention ||
preference == models.EmailNotificationsDisabled) { preference == models.EmailNotificationsDisabled) {
@ -229,7 +229,7 @@ func DeleteAccount(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsAccount"] = true 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) { if models.IsErrUserNotExist(err) {
loadAccountData(ctx) loadAccountData(ctx)

View file

@ -23,8 +23,8 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
allowDelete := ctx.IsUserSiteAdmin() || setting.Repository.AllowDeleteOfUnadoptedRepositories allowDelete := ctx.IsUserSiteAdmin() || setting.Repository.AllowDeleteOfUnadoptedRepositories
ctx.Data["allowDelete"] = allowDelete ctx.Data["allowDelete"] = allowDelete
dir := ctx.Form("id") dir := ctx.FormString("id")
action := ctx.Form("action") action := ctx.FormString("action")
ctxUser := ctx.User ctxUser := ctx.User
root := filepath.Join(models.UserPath(ctxUser.LowerName)) root := filepath.Join(models.UserPath(ctxUser.LowerName))

View file

@ -193,7 +193,7 @@ func KeysPost(ctx *context.Context) {
// DeleteKey response for delete user's SSH/GPG key // DeleteKey response for delete user's SSH/GPG key
func DeleteKey(ctx *context.Context) { func DeleteKey(ctx *context.Context) {
switch ctx.Form("type") { switch ctx.FormString("type") {
case "gpg": case "gpg":
if err := models.DeleteGPGKey(ctx.User, ctx.FormInt64("id")); err != nil { if err := models.DeleteGPGKey(ctx.User, ctx.FormInt64("id")); err != nil {
ctx.Flash.Error("DeleteGPGKey: " + err.Error()) ctx.Flash.Error("DeleteGPGKey: " + err.Error())
@ -265,5 +265,5 @@ func loadKeysData(ctx *context.Context) {
} }
ctx.Data["Principals"] = principals ctx.Data["Principals"] = principals
ctx.Data["VerifyingID"] = ctx.Form("verify_gpg") ctx.Data["VerifyingID"] = ctx.FormString("verify_gpg")
} }

View file

@ -25,7 +25,7 @@ func Security(ctx *context.Context) {
ctx.Data["PageIsSettingsSecurity"] = true ctx.Data["PageIsSettingsSecurity"] = true
ctx.Data["RequireU2F"] = true ctx.Data["RequireU2F"] = true
if ctx.Form("openid.return_to") != "" { if ctx.FormString("openid.return_to") != "" {
settingsOpenIDVerify(ctx) settingsOpenIDVerify(ctx)
return return
} }

View file

@ -78,7 +78,7 @@ func GetListLockHandler(ctx *context.Context) {
} else if limit < 0 { } else if limit < 0 {
limit = 0 limit = 0
} }
id := ctx.Form("id") id := ctx.FormString("id")
if id != "" { //Case where we request a specific id if id != "" { //Case where we request a specific id
v, err := strconv.ParseInt(id, 10, 64) v, err := strconv.ParseInt(id, 10, 64)
if err != nil { if err != nil {
@ -95,7 +95,7 @@ func GetListLockHandler(ctx *context.Context) {
return return
} }
path := ctx.Form("path") path := ctx.FormString("path")
if path != "" { //Case where we request a specific id if path != "" { //Case where we request a specific id
lock, err := models.GetLFSLock(repository, path) lock, err := models.GetLFSLock(repository, path)
if err != nil && !models.IsErrLFSLockNotExist(err) { if err != nil && !models.IsErrLFSLockNotExist(err) {