Permalink
Browse files

tpl/transform: Do not unescape input to highlight

Fixes #4179
  • Loading branch information...
bep committed Dec 29, 2017
1 parent 72903be commit c067f34558b82455b63b9ce8f5983b4b4849c7cf
Showing with 4 additions and 2 deletions.
  1. +1 −1 tpl/transform/transform.go
  2. +3 −1 tpl/transform/transform_test.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
}
@@ -69,6 +69,8 @@ func TestHighlight(t *testing.T) {
expect interface{}
}{
{"func boo() {}", "go", "", "boo"},
// Issue #4179
{`<Foo attr=" &lt; "></Foo>`, "xml", "", `&amp;lt;`},
{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)
}
}

0 comments on commit c067f34

Please sign in to comment.