From 0e89840337b9862990554c0cbbd377ffc5c2791e Mon Sep 17 00:00:00 2001 From: fuzhongyun <15339891972@163.com> Date: Fri, 14 Nov 2025 13:10:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E8=BD=AC=E4=B9=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/pkg/util/string.go | 10 +++++++++- internal/services/callback.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/pkg/util/string.go b/internal/pkg/util/string.go index 5ccac7d..81b7e29 100644 --- a/internal/pkg/util/string.go +++ b/internal/pkg/util/string.go @@ -1,6 +1,9 @@ package util -import "strings" +import ( + "encoding/json" + "strings" +) // 占位符替换 xxx{placeholder}xxx func ReplacePlaceholder(str string, placeholder string, value string) string { @@ -11,3 +14,8 @@ func ReplacePlaceholder(str string, placeholder string, value string) string { func BuildJumpLink(url string, text string) string { return "" + text + "" } + +func EscapeJSONString(s string) string { + b, _ := json.Marshal(s) + return string(b[1 : len(b)-1]) +} diff --git a/internal/services/callback.go b/internal/services/callback.go index f1a9447..f0ef4fd 100644 --- a/internal/services/callback.go +++ b/internal/services/callback.go @@ -145,7 +145,7 @@ func (s *CallbackService) handleDingTalkCallback(c *fiber.Ctx, env Envelope) err msg := data.Msg msg = util.ReplacePlaceholder(msg, "receivers", receivers) - msg = util.ReplacePlaceholder(msg, "detail_page", detailPage) + msg = util.ReplacePlaceholder(msg, "detail_page", util.EscapeJSONString(detailPage)) s.gateway.SendToUid(sessionID, []byte(msg))