From: Bjørn Erik Pedersen Date: Fri, 29 Dec 2017 08:52:43 +0000 (+0100) Subject: tpl/transform: Do not unescape input to highlight X-Git-Tag: v0.32~6 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=c067f34558b82455b63b9ce8f5983b4b4849c7cf;p=brevno-suite%2Fhugo tpl/transform: Do not unescape input to highlight Fixes #4179 --- diff --git a/tpl/transform/transform.go b/tpl/transform/transform.go index a94cc46e..7ec1fec0 100644 --- a/tpl/transform/transform.go +++ b/tpl/transform/transform.go @@ -55,7 +55,7 @@ func (ns *Namespace) Highlight(s interface{}, lang, opts string) (template.HTML, return "", err } - highlighted, _ := ns.deps.ContentSpec.Highlight(html.UnescapeString(ss), lang, opts) + highlighted, _ := ns.deps.ContentSpec.Highlight(ss, lang, opts) return template.HTML(highlighted), nil } diff --git a/tpl/transform/transform_test.go b/tpl/transform/transform_test.go index 429b206f..195a0f15 100644 --- a/tpl/transform/transform_test.go +++ b/tpl/transform/transform_test.go @@ -69,6 +69,8 @@ func TestHighlight(t *testing.T) { expect interface{} }{ {"func boo() {}", "go", "", "boo"}, + // Issue #4179 + {``, "xml", "", `<`}, {tstNoStringer{}, "go", "", false}, } { errMsg := fmt.Sprintf("[%d]", i) @@ -81,7 +83,7 @@ func TestHighlight(t *testing.T) { } require.NoError(t, err, errMsg) - assert.Contains(t, result, "boo", errMsg) + assert.Contains(t, result, test.expect.(string), errMsg) } }