mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-21 09:06:46 +09:00
fix(webhook): keep line breaks in Telegram rich messages (#39650)
Restore the old layout by converting line breaks (`\n`, `\r\n`, `\r`) to `<br>` in `createTelegramPayloadHTML`, after sanitizing, covering every Telegram payload type at once. Fixes https://github.com/go-gitea/gitea/issues/39649
This commit is contained in:
1 parent
a0b9ce05c4
commit
02da29f2da
2 files changed
+17
-18
No files matched your search
@@ -201,9 +201,12 @@ func (telegramConvertor) WorkflowJob(p *api.WorkflowJobPayload) (TelegramPayload
|
||||
|
||||
func createTelegramPayloadHTML(msgHTML string) TelegramPayload {
|
||||
// https://core.telegram.org/bots/api#formatting-options
|
||||
sanitized := strings.TrimSpace(string(markup.Sanitize(msgHTML)))
|
||||
// Rich messages collapse bare newlines like HTML, so keep line breaks as <br>.
|
||||
sanitized = strings.NewReplacer("\r\n", "<br>", "\r", "<br>", "\n", "<br>").Replace(sanitized)
|
||||
return TelegramPayload{
|
||||
RichMessage: InputRichMessage{
|
||||
HTML: strings.TrimSpace(string(markup.Sanitize(msgHTML))),
|
||||
HTML: sanitized,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user