Avoid issue info panic (#29625)

Fix #29624

(cherry picked from commit 1d2548949adf6046f330d27084efce6e63330e04)
This commit is contained in:
wxiaoguang 2024-03-06 21:12:44 +08:00 committed by Earl Warren
parent 95e682f104
commit a7830e8d87
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -395,10 +395,14 @@ func (a *Action) GetCreate() time.Time {
return a.CreatedUnix.AsTime() return a.CreatedUnix.AsTime()
} }
// GetIssueInfos returns a list of issues associated with // GetIssueInfos returns a list of associated information with the action.
// the action.
func (a *Action) GetIssueInfos() []string { 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. // GetIssueTitle returns the title of first issue associated with the action.