File fix-bigendian-json-encoding.patch of Package portainer

From: Claude AI Assistant
Date: Sat, 23 Nov 2025 12:00:00 +0000
Subject: [PATCH] Fix BigEndian JSON encoding issue on s390x

Use standard library encoding/json instead of segmentio/encoding/json
in the proxy utils layer to fix invalid JSON output on BigEndian
architectures (s390x, ppc64).

The segmentio/encoding library has a bug on BigEndian systems where
it fails to properly escape control characters (specifically newlines)
during JSON marshaling. This causes the Portainer UI to receive invalid
JSON when querying Docker services with multi-line arguments or
environment variables.

This fix specifically targets the proxy factory utils where Docker API
responses are re-marshaled after adding resource control metadata.
Using the standard library here ensures correct JSON escaping on all
architectures while maintaining performance for the rest of the codebase.

Tested-on: s390x (IBM LinuxONE)
Fixes: Invalid JSON in /api/endpoints/{id}/docker/services responses
---
 api/http/proxy/factory/utils/json.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/api/http/proxy/factory/utils/json.go b/api/http/proxy/factory/utils/json.go
index 3fc5b33bf..6145e27c0 100644
--- a/api/http/proxy/factory/utils/json.go
+++ b/api/http/proxy/factory/utils/json.go
@@ -2,12 +2,12 @@ package utils

 import (
 	"compress/gzip"
+	"encoding/json"
 	"errors"
 	"fmt"
 	"io"
 	"mime"

-	"github.com/segmentio/encoding/json"
 	"gopkg.in/yaml.v3"
 )

--
2.43.0
openSUSE Build Service is sponsored by