Merge pull request #26122 from hashicorp/alisdair/document-jsonencode-html-escape-behaviour
Document jsonencode HTML escape behaviour
This commit is contained in:
commit
42753e7dcc
|
@ -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": {
|
||||
|
|
|
@ -37,6 +37,11 @@ types, passing the `jsonencode` result to `jsondecode` will not produce an
|
|||
identical value, but the automatic type conversion rules mean that this is
|
||||
rarely a problem in practice.
|
||||
|
||||
When encoding strings, this function escapes some characters using
|
||||
Unicode escape sequences: replacing `<`, `>`, `&`, `U+2028`, and `U+2029` with
|
||||
`\u003c`, `\u003e`, `\u0026`, `\u2028`, and `\u2029`. This is to preserve
|
||||
compatibility with Terraform 0.11 behavior.
|
||||
|
||||
## Examples
|
||||
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue