summaryrefslogtreecommitdiffstats
path: root/modules/auth/repo_form.go
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2017-04-19 06:02:20 +0300
committerBo-Yi Wu <appleboy.tw@gmail.com>2017-04-19 11:02:20 +0800
commitf42ec6120e8a2830407027020b65391ebf8e7f59 (patch)
treeaee67e8f44d105ef957b27fe3777e38aa034baa6 /modules/auth/repo_form.go
parent941281ae12f0df84ffc73c279dc9e55f058e4703 (diff)
downloadgitea-f42ec6120e8a2830407027020b65391ebf8e7f59.tar.gz
gitea-f42ec6120e8a2830407027020b65391ebf8e7f59.zip
Better URL validation (#1507)
* Add correct git branch name validation * Change git refname validation error constant name * Implement URL validation based on GoLang url.Parse method * Backward compatibility with older Go compiler * Add git reference name validation unit tests * Remove unused variable in unit test * Implement URL validation based on GoLang url.Parse method * Backward compatibility with older Go compiler * Add url validation unit tests
Diffstat (limited to 'modules/auth/repo_form.go')
-rw-r--r--modules/auth/repo_form.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go
index dd3fbff7bf..c56e76c871 100644
--- a/modules/auth/repo_form.go
+++ b/modules/auth/repo_form.go
@@ -87,7 +87,7 @@ func (f MigrateRepoForm) ParseRemoteAddr(user *models.User) (string, error) {
type RepoSettingForm struct {
RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
Description string `binding:"MaxSize(255)"`
- Website string `binding:"Url;MaxSize(255)"`
+ Website string `binding:"ValidUrl;MaxSize(255)"`
Interval string
MirrorAddress string
Private bool
@@ -143,7 +143,7 @@ func (f WebhookForm) ChooseEvents() bool {
// NewWebhookForm form for creating web hook
type NewWebhookForm struct {
- PayloadURL string `binding:"Required;Url"`
+ PayloadURL string `binding:"Required;ValidUrl"`
ContentType int `binding:"Required"`
Secret string
WebhookForm
@@ -156,7 +156,7 @@ func (f *NewWebhookForm) Validate(ctx *macaron.Context, errs binding.Errors) bin
// NewSlackHookForm form for creating slack hook
type NewSlackHookForm struct {
- PayloadURL string `binding:"Required;Url"`
+ PayloadURL string `binding:"Required;ValidUrl"`
Channel string `binding:"Required"`
Username string
IconURL string
@@ -323,7 +323,7 @@ type EditRepoFileForm struct {
CommitSummary string `binding:"MaxSize(100)"`
CommitMessage string
CommitChoice string `binding:"Required;MaxSize(50)"`
- NewBranchName string `binding:"AlphaDashDot;MaxSize(100)"`
+ NewBranchName string `binding:"GitRefName;MaxSize(100)"`
LastCommit string
}
@@ -356,7 +356,7 @@ type UploadRepoFileForm struct {
CommitSummary string `binding:"MaxSize(100)"`
CommitMessage string
CommitChoice string `binding:"Required;MaxSize(50)"`
- NewBranchName string `binding:"AlphaDashDot;MaxSize(100)"`
+ NewBranchName string `binding:"GitRefName;MaxSize(100)"`
Files []string
}
@@ -387,7 +387,7 @@ type DeleteRepoFileForm struct {
CommitSummary string `binding:"MaxSize(100)"`
CommitMessage string
CommitChoice string `binding:"Required;MaxSize(50)"`
- NewBranchName string `binding:"AlphaDashDot;MaxSize(100)"`
+ NewBranchName string `binding:"GitRefName;MaxSize(100)"`
}
// Validate validates the fields