From 4696e63b27d640af09c99ac2c1696a18115d7e36 Mon Sep 17 00:00:00 2001 From: wrench Date: Mon, 12 Sep 2022 20:04:09 +0530 Subject: [PATCH] FIX: escape text incase if html tags are present --- utils/telegram.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/telegram.go b/utils/telegram.go index d024ebf..84975d9 100644 --- a/utils/telegram.go +++ b/utils/telegram.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "github-telegram-notify/types" + "html" "io/ioutil" "net/http" "net/url" @@ -14,7 +15,8 @@ func SendMessage(token string, chatID string, text string, markupText string, ma req_url, _ := url.Parse(fmt.Sprint(apiBaseUri, "/bot", token, "/sendMessage")) params := url.Values{} params.Set("chat_id", chatID) - params.Set("text", text) + escaped_text := html.EscapeString(text) + params.Set("text", escaped_text) params.Set("parse_mode", "html") params.Set("disable_web_page_preview", "true") kyb, err := json.Marshal(map[string][][]map[string]string{