diff --git a/modules/markup/html.go b/modules/markup/html.go index aba287e0fd..58021f5cb5 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -557,9 +557,13 @@ func createCodeLink(href, content, class string) *html.Node { a.Attr = append(a.Attr, html.Attribute{Key: "class", Val: class}) } + unescaped, err := url.QueryUnescape(content) + if err != nil { + unescaped = content + } text := &html.Node{ Type: html.TextNode, - Data: content, + Data: unescaped, } code := &html.Node{ diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index 3794673e82..11a6290ca3 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -91,6 +91,9 @@ func TestRender_Commits(t *testing.T) { test(sha[:14]+".", `
`+expected14+`.
`) test(sha[:14]+",", ``+expected14+`,
`) test("["+sha[:14]+"]", `[`+expected14+`]
`) + + fileStrangeChars := util.URLJoin(repo, "src", "commit", "eeb243c3395e1921c5d90e73bd739827251fc99d", "path", "to", "file%20%23.txt") + test(fileStrangeChars, ``) } func TestRender_CrossReferences(t *testing.T) {