chore: form binding trim space (#38978)

Use "binding:TrimSpace" instead of fragile IsEmptyString

And fix a bug in locale's `HasKey`: it should also try the default
language if current language doesn't have the translation key, a new
test is added.
This commit is contained in:
wxiaoguang
2026-08-19 12:50:06 +00:00
committed by GitHub
parent c121f02a7e
commit f261adb53f
17 changed files with 21 additions and 71 deletions
-7
View File
@@ -13,7 +13,6 @@ import (
"gitea.dev/modules/git"
"gitea.dev/modules/setting"
api "gitea.dev/modules/structs"
"gitea.dev/modules/util"
"gitea.dev/modules/web"
"gitea.dev/services/context"
"gitea.dev/services/convert"
@@ -56,12 +55,6 @@ func NewWikiPage(ctx *context.APIContext) {
// "$ref": "#/responses/repoArchivedError"
form := web.GetForm[*api.CreateWikiPageOptions](ctx)
if util.IsEmptyString(form.Title) {
ctx.APIError(http.StatusBadRequest, "title is required")
return
}
wikiName := wiki_service.UserTitleToWebPath("", form.Title)
if len(form.Message) == 0 {