From 99812a80fd1b1336e992c0967be603e146f78729 Mon Sep 17 00:00:00 2001 From: Thibault Meyer <0xbaadf00d@users.noreply.github.com> Date: Wed, 10 Aug 2016 20:35:06 +0200 Subject: [PATCH] Fix #3420: Bad commit URL generation (#3424) --- modules/markdown/markdown.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/markdown/markdown.go b/modules/markdown/markdown.go index 20fe2a77f..92a615499 100644 --- a/modules/markdown/markdown.go +++ b/modules/markdown/markdown.go @@ -260,12 +260,9 @@ func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string, metas map[string // RenderSha1CurrentPattern renders SHA1 strings to corresponding links that assumes in the same repository. func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte { - ms := Sha1CurrentPattern.FindAll(rawBytes, -1) - for _, m := range ms { - rawBytes = bytes.Replace(rawBytes, m, []byte(fmt.Sprintf( - `%s`, urlPrefix, m, base.ShortSha(string(m)))), -1) - } - return rawBytes + return []byte(Sha1CurrentPattern.ReplaceAllStringFunc(string(rawBytes[:]), func(m string) string { + return fmt.Sprintf(`%s`, urlPrefix, m, base.ShortSha(string(m))) + })) } // RenderSpecialLink renders mentions, indexes and SHA1 strings to corresponding links.