Skip to content

Commit

Permalink
Escape the commit message on issues update and title in telegram hook (
Browse files Browse the repository at this point in the history
  • Loading branch information
zeripath committed May 11, 2019
1 parent 3c8b4fc commit 7908925
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion models/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package models
import (
"encoding/json"
"fmt"
"html"
"path"
"regexp"
"strconv"
Expand Down Expand Up @@ -580,7 +581,7 @@ func UpdateIssuesCommit(doer *User, repo *Repository, commits []*PushCommit, bra
}
refMarked[issue.ID] = true

message := fmt.Sprintf(`<a href="%s/commit/%s">%s</a>`, repo.Link(), c.Sha1, c.Message)
message := fmt.Sprintf(`<a href="%s/commit/%s">%s</a>`, repo.Link(), c.Sha1, html.EscapeString(c.Message))
if err = CreateRefComment(doer, refRepo, issue, message, c.Sha1); err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion models/webhook_telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package models
import (
"encoding/json"
"fmt"
"html"
"strings"

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

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

0 comments on commit 7908925

Please sign in to comment.