Skip to content

Commit

Permalink
Avoid issue info panic (go-gitea#29625)
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang authored and GiteaBot committed Mar 6, 2024
1 parent 2f1eb61 commit b2842df
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 b2842df

Please sign in to comment.