summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorThibault Meyer <0xbaadf00d@users.noreply.github.com>2016-08-10 20:35:06 +0200
committer无闻 <u@gogs.io>2016-08-10 11:35:06 -0700
commit99812a80fd1b1336e992c0967be603e146f78729 (patch)
tree25c0138e4ed76de52dbd099dba6e4aed81b19970 /modules
parent8ad92bb8a4d5aafd15781d35842b0b1273f9db26 (diff)
downloadgitea-99812a80fd1b1336e992c0967be603e146f78729.tar.gz
gitea-99812a80fd1b1336e992c0967be603e146f78729.zip
Fix #3420: Bad commit URL generation (#3424)
Diffstat (limited to 'modules')
-rw-r--r--modules/markdown/markdown.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/modules/markdown/markdown.go b/modules/markdown/markdown.go
index 20fe2a77fe..92a6154993 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(
- `<a href="%s/commit/%s"><code>%s</code></a>`, urlPrefix, m, base.ShortSha(string(m)))), -1)
- }
- return rawBytes
+ return []byte(Sha1CurrentPattern.ReplaceAllStringFunc(string(rawBytes[:]), func(m string) string {
+ return fmt.Sprintf(`<a href="%s/commit/%s"><code>%s</code></a>`, urlPrefix, m, base.ShortSha(string(m)))
+ }))
}
// RenderSpecialLink renders mentions, indexes and SHA1 strings to corresponding links.