Select the types of activity you want to include in your feed.
Fix possible panic (#17694)
- The code will get the first and second character `link[{0,1]]`.
However in a rare case the `link` could have 1 character and thus the
`link[1]` will create a panic.
···108108// avatarLink returns user avatar absolute link.
109109func (repo *Repository) avatarLink(e db.Engine) string {
110110 link := repo.relAvatarLink(e)
111111- // link may be empty!
112112- if len(link) > 0 {
113113- if link[0] == '/' && link[1] != '/' {
114114- return setting.AppURL + strings.TrimPrefix(link, setting.AppSubURL)[1:]
115115- }
111111+ // we only prepend our AppURL to our known (relative, internal) avatar link to get an absolute URL
112112+ if strings.HasPrefix(link, "/") && !strings.HasPrefix(link, "//") {
113113+ return setting.AppURL + strings.TrimPrefix(link, setting.AppSubURL)[1:]
116114 }
115115+ // otherwise, return the link as it is
117116 return link
118117}
119118