Skip to content

Commit 7908925

Browse files
committed
Escape the commit message on issues update and title in telegram hook (go-gitea#6901)
1 parent 3c8b4fc commit 7908925

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

models/action.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package models
88
import (
99
"encoding/json"
1010
"fmt"
11+
"html"
1112
"path"
1213
"regexp"
1314
"strconv"
@@ -580,7 +581,7 @@ func UpdateIssuesCommit(doer *User, repo *Repository, commits []*PushCommit, bra
580581
}
581582
refMarked[issue.ID] = true
582583

583-
message := fmt.Sprintf(`<a href="%s/commit/%s">%s</a>`, repo.Link(), c.Sha1, c.Message)
584+
message := fmt.Sprintf(`<a href="%s/commit/%s">%s</a>`, repo.Link(), c.Sha1, html.EscapeString(c.Message))
584585
if err = CreateRefComment(doer, refRepo, issue, message, c.Sha1); err != nil {
585586
return err
586587
}

models/webhook_telegram.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package models
77
import (
88
"encoding/json"
99
"fmt"
10+
"html"
1011
"strings"
1112

1213
"code.gitea.io/gitea/modules/git"
@@ -169,7 +170,7 @@ func getTelegramIssuesPayload(p *api.IssuePayload) (*TelegramPayload, error) {
169170

170171
func getTelegramIssueCommentPayload(p *api.IssueCommentPayload) (*TelegramPayload, error) {
171172
url := fmt.Sprintf("%s/issues/%d#%s", p.Repository.HTMLURL, p.Issue.Index, CommentHashTag(p.Comment.ID))
172-
title := fmt.Sprintf(`<a href="%s">#%d %s</a>`, url, p.Issue.Index, p.Issue.Title)
173+
title := fmt.Sprintf(`<a href="%s">#%d %s</a>`, url, p.Issue.Index, html.EscapeString(p.Issue.Title))
173174
var text string
174175
switch p.Action {
175176
case api.HookIssueCommentCreated:

0 commit comments

Comments
 (0)