summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLanre Adelowo <adelowomailbox@gmail.com>2019-01-21 12:45:32 +0100
committerLauris BH <lauris@nix.lv>2019-01-21 13:45:32 +0200
commite1fcd6b7427d1e7c43ac9dcb32462a8e6d77c905 (patch)
tree46b617eb487061dcb8bfd3da7175d7bd23f51e6d /routers
parent8a92544a3e06e0c1146ee6d0c340d662e1b0633c (diff)
downloadgitea-e1fcd6b7427d1e7c43ac9dcb32462a8e6d77c905.tar.gz
gitea-e1fcd6b7427d1e7c43ac9dcb32462a8e6d77c905.zip
Disallow empty titles (#5785)
* add util method and tests * make sure the title of an issue cannot be empty * wiki title cannot be empty * pull request title cannot be empty * update to make use of the new util methof
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/issue.go7
-rw-r--r--routers/repo/pull.go11
-rw-r--r--routers/repo/wiki.go5
3 files changed, 22 insertions, 1 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 6c6c2612bf..8e0b22eb62 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -355,7 +355,7 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles
}
}
-// NewIssue render createing issue page
+// NewIssue render creating issue page
func NewIssue(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
ctx.Data["PageIsIssueList"] = true
@@ -494,6 +494,11 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
return
}
+ if util.IsEmptyString(form.Title) {
+ ctx.RenderWithErr(ctx.Tr("repo.issues.new.title_empty"), tplIssueNew, form)
+ return
+ }
+
issue := &models.Issue{
RepoID: repo.ID,
Title: form.Title,
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 688a033fdb..eecb4809a6 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -22,6 +22,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/setting"
+ "code.gitea.io/gitea/modules/util"
"github.com/Unknwon/com"
)
@@ -875,6 +876,16 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm)
return
}
+ if util.IsEmptyString(form.Title) {
+ PrepareCompareDiff(ctx, headUser, headRepo, headGitRepo, prInfo, baseBranch, headBranch)
+ if ctx.Written() {
+ return
+ }
+
+ ctx.RenderWithErr(ctx.Tr("repo.issues.new.title_empty"), tplComparePull, form)
+ return
+ }
+
patch, err := headGitRepo.GetPatch(prInfo.MergeBase, headBranch)
if err != nil {
ctx.ServerError("GetPatch", err)
diff --git a/routers/repo/wiki.go b/routers/repo/wiki.go
index 7e52129773..4cea3c890a 100644
--- a/routers/repo/wiki.go
+++ b/routers/repo/wiki.go
@@ -341,6 +341,11 @@ func NewWikiPost(ctx *context.Context, form auth.NewWikiForm) {
return
}
+ if util.IsEmptyString(form.Title) {
+ ctx.RenderWithErr(ctx.Tr("repo.issues.new.title_empty"), tplWikiNew, form)
+ return
+ }
+
wikiName := models.NormalizeWikiName(form.Title)
if err := ctx.Repo.Repository.AddWikiPage(ctx.User, wikiName, form.Content, form.Message); err != nil {
if models.IsErrWikiReservedName(err) {