Skip to content

Commit c067f34

Browse files
committed
tpl/transform: Do not unescape input to highlight
Fixes #4179
1 parent 72903be commit c067f34

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

‎tpl/transform/transform.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (ns *Namespace) Highlight(s interface{}, lang, opts string) (template.HTML,
5555
return "", err
5656
}
5757

58-
highlighted, _ := ns.deps.ContentSpec.Highlight(html.UnescapeString(ss), lang, opts)
58+
highlighted, _ := ns.deps.ContentSpec.Highlight(ss, lang, opts)
5959
return template.HTML(highlighted), nil
6060
}
6161

‎tpl/transform/transform_test.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ func TestHighlight(t *testing.T) {
6969
expect interface{}
7070
}{
7171
{"func boo() {}", "go", "", "boo"},
72+
// Issue #4179
73+
{`<Foo attr=" &lt; "></Foo>`, "xml", "", `&amp;lt;`},
7274
{tstNoStringer{}, "go", "", false},
7375
} {
7476
errMsg := fmt.Sprintf("[%d]", i)
@@ -81,7 +83,7 @@ func TestHighlight(t *testing.T) {
8183
}
8284

8385
require.NoError(t, err, errMsg)
84-
assert.Contains(t, result, "boo", errMsg)
86+
assert.Contains(t, result, test.expect.(string), errMsg)
8587
}
8688
}
8789

0 commit comments

Comments
 (0)