Przeglądaj źródła

Avoid issue info panic (#29625) (#29632)

Backport #29625 by wxiaoguang

Fix #29624

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
tags/v1.21.8
Giteabot 3 miesięcy temu
rodzic
commit
6ee58a0ac2
No account linked to committer's email address
1 zmienionych plików z 7 dodań i 3 usunięć
  1. 7
    3
      models/activities/action.go

+ 7
- 3
models/activities/action.go Wyświetl plik

@@ -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.

Ładowanie…
Anuluj
Zapisz