From 4796b7dd690c47089dffc8c721fa5d3e9613e9ae Mon Sep 17 00:00:00 2001 From: JustSong Date: Mon, 8 May 2023 22:39:38 +0800 Subject: [PATCH] fix: check if the custom channel's server address is valid --- channel/custom.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/channel/custom.go b/channel/custom.go index 830f96abf..7e96daacc 100644 --- a/channel/custom.go +++ b/channel/custom.go @@ -3,6 +3,7 @@ package channel import ( "bytes" "errors" + "message-pusher/common" "message-pusher/model" "net/http" "strings" @@ -13,6 +14,9 @@ func SendCustomMessage(message *model.Message, user *model.User, channel_ *model if strings.HasPrefix(url, "http:") { return errors.New("自定义通道必须使用 HTTPS 协议") } + if strings.HasPrefix(url, common.ServerAddress) { + return errors.New("自定义通道不能使用本服务地址") + } template := channel_.Other template = strings.Replace(template, "$url", message.URL, -1) template = strings.Replace(template, "$to", message.To, -1)