api: Don't HTML escape application/json responses

An HTTP response with Content-Type application/json does not need
to be HTML escaped. Doing this causes encoding issues in the Podman
REST API output as seen in the issue:

Fixes #17769

Remove the HTML escaping from Content-Type: application/json responses.

Signed-off-by: Stef Walter <stef@thewalter.net>
This commit is contained in:
Stef Walter 2025-06-14 13:03:57 +02:00
parent 17a386a19d
commit 5a952362dd
1 changed files with 1 additions and 1 deletions

View File

@ -120,7 +120,7 @@ func WriteJSON(w http.ResponseWriter, code int, value interface{}) {
w.WriteHeader(code)
coder := json.NewEncoder(w)
coder.SetEscapeHTML(true)
coder.SetEscapeHTML(false)
if err := coder.Encode(value); err != nil {
logrus.Errorf("Unable to write json: %q", err)
}