Skip to content

Commit

Permalink
exclude /jpages/ urls from the charset encoding conversion because
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jens-maus committed Jan 4, 2023
1 parent d040ce0 commit e4418b6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions buildroot-external/overlay/base-raspmatic_oci/bin/ha-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <mail@jens-maus.de>
// Copyright (c) 2021-2023 Jens Maus <mail@jens-maus.de>
//
// Apache 2.0 License applies
//
Expand Down Expand Up @@ -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');
Expand All @@ -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');
Expand Down

0 comments on commit e4418b6

Please sign in to comment.