Skip to content

Commit

Permalink
Avoid issue info panic (#29625) (#29632)
Browse files Browse the repository at this point in the history
Backport #29625 by wxiaoguang

Fix #29624

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
  • Loading branch information
GiteaBot and wxiaoguang authored Mar 6, 2024
1 parent 2f1eb61 commit 6ee58a0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions models/activities/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,14 @@ func (a *Action) GetCreate() time.Time {
return a.CreatedUnix.AsTime()
}

// GetIssueInfos returns a list of issues associated with
// the action.
// GetIssueInfos returns a list of associated information with the action.
func (a *Action) GetIssueInfos() []string {
return strings.SplitN(a.Content, "|", 3)
// make sure it always returns 3 elements, because there are some access to the a[1] and a[2] without checking the length
ret := strings.SplitN(a.Content, "|", 3)
for len(ret) < 3 {
ret = append(ret, "")
}
return ret
}

// GetIssueTitle returns the title of first issue associated with the action.
Expand Down

0 comments on commit 6ee58a0

Please sign in to comment.