0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-25 17:32:45 +01:00

Safely detect urlPrefix in the format /:owner/:repo

This commit is contained in:
Howl 2015-11-15 22:22:25 +01:00
parent 85c58eba90
commit ca5678da32

View file

@ -168,9 +168,9 @@ func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte {
} }
func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string) []byte { func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string) []byte {
// Remove unnecessary things after username and reponame in prefix if i := strings.Index(urlPrefix, "/src"); i != -1 {
// (otherwise stuff like /:user/:repo/src/master/issues/1 would happen) urlPrefix = urlPrefix[:i]
urlPrefix = strings.Join(strings.Split(urlPrefix, "/")[:3], "/") }
ms := issueIndexPattern.FindAll(rawBytes, -1) ms := issueIndexPattern.FindAll(rawBytes, -1)
for _, m := range ms { for _, m := range ms {
var space string var space string