tpl/transform: Do not unescape input to highlight

Fixes #4179
This commit is contained in:
Bjørn Erik Pedersen 2017-12-29 09:52:43 +01:00
parent 72903be587
commit c067f34558
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
2 changed files with 4 additions and 2 deletions

View file

@ -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
}

View file

@ -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)
}
}