aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-03-06 21:12:44 +0800
committerGitHub <noreply@github.com>2024-03-06 13:12:44 +0000
commit1d2548949adf6046f330d27084efce6e63330e04 (patch)
tree2272b609f08df0f47e10d10cfa8c8d86726403d9
parente308d25f1b2fe24b4735432b05e5e221879a2705 (diff)
downloadgitea-1d2548949adf6046f330d27084efce6e63330e04.tar.gz
gitea-1d2548949adf6046f330d27084efce6e63330e04.zip
Avoid issue info panic (#29625)
Fix #29624
-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 fcc97e3872..36205eedd1 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.