From 8e40f86d2c66268fcd4ff80ff5a35ba66cece581 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 4 Feb 2016 22:51:40 -0500 Subject: #2556 handle space in image URL --- modules/base/markdown.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'modules/base') diff --git a/modules/base/markdown.go b/modules/base/markdown.go index 265deffa..8b3c8f43 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -157,6 +157,8 @@ func (options *CustomRender) ListItem(out *bytes.Buffer, text []byte, flags int) var ( svgSuffix = []byte(".svg") svgSuffixWithMark = []byte(".svg?") + spaceBytes = []byte(" ") + spaceEncodedBytes = []byte("%20") ) func (r *CustomRender) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte) { @@ -172,7 +174,8 @@ func (r *CustomRender) Image(out *bytes.Buffer, link []byte, title []byte, alt [ if link[0] != '/' { prefix += "/" } - link = []byte(prefix + string(link)) + link = bytes.Replace([]byte((prefix + string(link))), spaceBytes, spaceEncodedBytes, -1) + fmt.Println(333, string(link)) } } -- cgit v1.2.3