lang: Add test for jsonencode entity escaping

The encoding/json package escapes some HTML-specific characters to
prevent JSON from being misinterpreted when in the context of an HTML
document. Terraform 0.11 used this behaviour, and to preserve backwards
compatibility we are continuing to do so moving forward.

This commit adds an explicit test to document that this is intentional,
not a bug.
pull/26122/head
Alisdair McDiarmid 6 years ago
parent 79e35941f5
commit c7568ccceb

@ -472,6 +472,12 @@ func TestFunctions(t *testing.T) {
`jsonencode({"hello"="world"})`,
cty.StringVal("{\"hello\":\"world\"}"),
},
// We are intentionally choosing to escape <, >, and & characters
// to preserve backwards compatibility with Terraform 0.11
{
`jsonencode({"hello"="<cats & kittens>"})`,
cty.StringVal("{\"hello\":\"\\u003ccats \\u0026 kittens\\u003e\"}"),
},
},
"keys": {

Loading…
Cancel
Save