Browse Source

modules/markdown: fix wrong raw link to internal images

pull/4248/head
Unknwon 8 years ago
parent
commit
8b73c8076f
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 2
      gogs.go
  2. 19
      modules/markdown/markdown.go
  3. 2
      templates/.VERSION

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
const APP_VER = "0.10.5.0304"
const APP_VER = "0.10.6.0305"
func init() {
setting.AppVer = APP_VER

19
modules/markdown/markdown.go

@ -343,16 +343,25 @@ func wrapImgWithLink(urlPrefix string, buf *bytes.Buffer, token html.Token) {
return
}
buf.WriteString(`<a href="`)
buf.WriteString(src)
buf.WriteString(`">`)
// Prepend repository base URL for internal links
if !isLink([]byte(src)) {
needPrepend := !isLink([]byte(src))
if needPrepend {
urlPrefix = strings.Replace(urlPrefix, "/src/", "/raw/", 1)
if src[0] != '/' {
urlPrefix += "/"
}
}
buf.WriteString(`<a href="`)
if needPrepend {
buf.WriteString(urlPrefix)
buf.WriteString(src)
} else {
buf.WriteString(src)
}
buf.WriteString(`">`)
if needPrepend {
src = strings.Replace(urlPrefix+string(src), " ", "%20", -1)
buf.WriteString(`<img src="`)
buf.WriteString(src)

2
templates/.VERSION

@ -1 +1 @@
0.10.5.0304
0.10.6.0305
Loading…
Cancel
Save