From e4418b685b87070194c902f9a31f73cc3553a0fe Mon Sep 17 00:00:00 2001 From: Jens Maus Date: Wed, 4 Jan 2023 13:08:11 +0100 Subject: [PATCH] exclude /jpages/ urls from the charset encoding conversion because HMIPServer always seem to send in utf-8 but unfortunately without explicitly adding 'charset=utf-8' to the content-type. This resulted in broken charset conversions like for umlauts if used in the groups, diagram and other HMIPServer delivered WebUI portions. This fixes #2139 --- .../overlay/base-raspmatic_oci/bin/ha-proxy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/buildroot-external/overlay/base-raspmatic_oci/bin/ha-proxy.js b/buildroot-external/overlay/base-raspmatic_oci/bin/ha-proxy.js index b59f2bb038..739b8c2c70 100755 --- a/buildroot-external/overlay/base-raspmatic_oci/bin/ha-proxy.js +++ b/buildroot-external/overlay/base-raspmatic_oci/bin/ha-proxy.js @@ -5,7 +5,7 @@ // Home-Assistent UI so that the Ingress-based HA UI is able to embed // the WebUI. // -// Copyright (c) 2021 Jens Maus +// Copyright (c) 2021-2023 Jens Maus // // Apache 2.0 License applies // @@ -41,7 +41,7 @@ const apiProxy = createProxyMiddleware('/', { var body; // if this a textual response body we make sure to prepend the ingress path - if(proxyRes.headers['content-type'].toLowerCase().includes('utf-8')) { + if(proxyRes.headers['content-type'].toLowerCase().includes('utf-8') || proxyRes.req.path.includes('/jpages/')) { body = responseBody.toString('utf8'); } else { body = responseBody.toString('latin1'); @@ -57,7 +57,7 @@ const apiProxy = createProxyMiddleware('/', { 'window.location.href=\'' + req.headers['x-ingress-path'] + '/index.htm\''); // convert back to a Buffer in the right character encoding - if(typeof(req.headers['content-type']) === 'undefined') { + if(typeof(req.headers['content-type']) === 'undefined' && req.path.includes('/jpages/') === false) { return new Buffer.from(body, 'latin1'); } else { return new Buffer.from(body, 'utf8');