ref: c067f34558b82455b63b9ce8f5983b4b4849c7cf
parent: 72903be587e9c4e3644f60b11e26238ec03da2db
author: Bjørn Erik Pedersen <[email protected]>
date: Fri Dec 29 04:52:43 EST 2017
tpl/transform: Do not unescape input to highlight Fixes #4179
--- a/tpl/transform/transform.go
+++ b/tpl/transform/transform.go
@@ -55,7 +55,7 @@
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
}
--- a/tpl/transform/transform_test.go
+++ b/tpl/transform/transform_test.go
@@ -69,6 +69,8 @@
expect interface{}
}{
{"func boo() {}", "go", "", "boo"},
+ // Issue #4179
+ {`<Foo attr=" < "></Foo>`, "xml", "", `&lt;`},
{tstNoStringer{}, "go", "", false},
} {
errMsg := fmt.Sprintf("[%d]", i)
@@ -81,7 +83,7 @@
}
require.NoError(t, err, errMsg)
- assert.Contains(t, result, "boo", errMsg)
+ assert.Contains(t, result, test.expect.(string), errMsg)
}
}