aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2024-03-06 21:33:29 +0800
committerGitHub <noreply@github.com>2024-03-06 13:33:29 +0000
commit6ee58a0ac20fa1e7d328ede71f3df4c86fc41ab3 (patch)
tree61c5b8c2a140103be0b822d972e4e1025de42ab5
parent2f1eb619bc19a9b172062ba17789356bbdaa259d (diff)
downloadgitea-6ee58a0ac20fa1e7d328ede71f3df4c86fc41ab3.tar.gz
gitea-6ee58a0ac20fa1e7d328ede71f3df4c86fc41ab3.zip
Avoid issue info panic (#29625) (#29632)
Backport #29625 by wxiaoguang Fix #29624 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
-rw-r--r--models/activities/action.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/models/activities/action.go b/models/activities/action.go
index bf56f27a8b..238c2f2e92 100644
--- a/models/activities/action.go
+++ b/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.