Files
Ali AsgharandGitHub a0993a8dcf [pdata] don't HTML-escape ValueTypeMap/Slice AsString output (#15108)
## Description

`pcommon.Value.AsString` uses `json.Marshal` for `ValueTypeMap` and
`ValueTypeSlice`, which HTML-escapes `<`, `>`, and `&` into `\u003c`,
`\u003e`, and `\u0026`. This is inconsistent with `ValueTypeStr`, which
returns the raw string, and corrupts structured log bodies whose content
happens to contain those characters.

```
"<".AsString()       -> "<"
["<"].AsString()     -> ["\u003c"]   // surprising
{"key":"<"}.AsString() -> {"key":"\u003c"} // surprising
```

Switch to `json.Encoder` with `SetEscapeHTML(false)` so that maps and
slices serialize the same way strings do.

Closes #14662

## Link to tracking Issue
#14662

## Testing

Added `map_with_html_characters` and `slice_with_html_characters`
sub-tests to `TestValueAsString`. `go test ./pcommon/... -run
TestValueAsString` passes (14/14).

## Documentation

.chloggen entry added.

---------

Signed-off-by: alliasgher <[email protected]>
Signed-off-by: Ali <[email protected]>
2026-04-30 14:14:44 +00:00
..