Skip to content

Commit 1d25489

Browse files
authored
Avoid issue info panic (#29625)
Fix #29624
1 parent e308d25 commit 1d25489

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

models/activities/action.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,14 @@ func (a *Action) GetCreate() time.Time {
393393
return a.CreatedUnix.AsTime()
394394
}
395395

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

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

0 commit comments

Comments
 (0)