mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-05 14:37:41 +02:00
Slack webhook channel name cannot be empty or just contain an hashtag (#4786)
This commit is contained in:
1 parent
6e03390aa8
commit
be48397945
6 files changed
+69
-5
No files matched your search
@@ -5,14 +5,16 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
api "code.gitea.io/sdk/gitea"
|
||||
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/routers/api/v1/convert"
|
||||
"code.gitea.io/gitea/routers/utils"
|
||||
api "code.gitea.io/sdk/gitea"
|
||||
|
||||
"github.com/Unknwon/com"
|
||||
)
|
||||
|
||||
@@ -119,8 +121,14 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, orgID, repoID
|
||||
ctx.Error(422, "", "Missing config option: channel")
|
||||
return nil, false
|
||||
}
|
||||
|
||||
if !utils.IsValidSlackChannel(channel) {
|
||||
ctx.Error(400, "", "Invalid slack channel name")
|
||||
return nil, false
|
||||
}
|
||||
|
||||
meta, err := json.Marshal(&models.SlackMeta{
|
||||
Channel: channel,
|
||||
Channel: strings.TrimSpace(channel),
|
||||
Username: form.Config["username"],
|
||||
IconURL: form.Config["icon_url"],
|
||||
Color: form.Config["color"],
|
||||
|
||||
Reference in new issue
Block a user