mirror of
https://github.com/go-gitea/gitea
synced 2025-07-16 07:18:37 +00:00
Validate hex colors when creating/editing labels (#34623)
Resolves #34618. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
26
routers/web/shared/label/label.go
Normal file
26
routers/web/shared/label/label.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package label
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/label"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/services/context"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
)
|
||||
|
||||
func GetLabelEditForm(ctx *context.Context) *forms.CreateLabelForm {
|
||||
form := web.GetForm(ctx).(*forms.CreateLabelForm)
|
||||
if ctx.HasError() {
|
||||
ctx.JSONError(ctx.Data["ErrorMsg"].(string))
|
||||
return nil
|
||||
}
|
||||
var err error
|
||||
form.Color, err = label.NormalizeColor(form.Color)
|
||||
if err != nil {
|
||||
ctx.JSONError(ctx.Tr("repo.issues.label_color_invalid"))
|
||||
return nil
|
||||
}
|
||||
return form
|
||||
}
|
Reference in New Issue
Block a user