Avoid issue info panic (#29625)

Fix #29624
pull/29432/head^2
wxiaoguang 11 months ago committed by GitHub
parent e308d25f1b
commit 1d2548949a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      models/activities/action.go

@ -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.

Loading…
Cancel
Save