diff --git a/packages/insomnia/src/ui/components/viewers/__tests__/response-viewer.test.tsx b/packages/insomnia/src/ui/components/viewers/__tests__/response-viewer.test.tsx
index bb10b4cef..5f44577a5 100644
--- a/packages/insomnia/src/ui/components/viewers/__tests__/response-viewer.test.tsx
+++ b/packages/insomnia/src/ui/components/viewers/__tests__/response-viewer.test.tsx
@@ -1,5 +1,6 @@
import { beforeEach, describe, expect, it, jest } from '@jest/globals';
import { render } from '@testing-library/react';
+import iconv from 'iconv-lite';
import React from 'react';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
@@ -86,4 +87,18 @@ describe('', () => {
expect(responseWebView).toBeInTheDocument();
expect(mockRenderWithProps).not.toHaveBeenCalledWith();
});
+
+ it('should decode ISO-8859-1 HTML content and render encoded in UTF-8', async () => {
+ const TEST_STRING = 'Viel Glück';
+ const responseWebView = await getResponseViewerChild({
+ contentType: 'text/html; charset=iso-8859-1',
+ getBody: () => Buffer.from(iconv.encode(TEST_STRING, 'iso-8859-1')),
+ }, 'ResponseWebView');
+
+ Object.assign(responseWebView, { loadURL: (url: string) => {
+ expect(url).toEqual(`data:text/html; charset=utf-8,${encodeURIComponent(TEST_STRING)}`);
+ } });
+
+ responseWebView.dispatchEvent(new Event('dom-ready'));
+ });
});
diff --git a/packages/insomnia/src/ui/components/viewers/response-viewer.tsx b/packages/insomnia/src/ui/components/viewers/response-viewer.tsx
index 40fea3d18..36144701b 100644
--- a/packages/insomnia/src/ui/components/viewers/response-viewer.tsx
+++ b/packages/insomnia/src/ui/components/viewers/response-viewer.tsx
@@ -253,7 +253,6 @@ export const ResponseViewer = ({
return (
= ({ webpreferences, body, contentType, url }) => {
+export const ResponseWebView: FC = ({ webpreferences, body, url }) => {
const webviewRef = useRef(null);
useEffect(() => {
@@ -15,7 +14,7 @@ export const ResponseWebView: FC = ({ webpreferences, body, contentType,
if (webview) {
webview.removeEventListener('dom-ready', handleDOMReady);
const bodyWithBase = body.replace('', ``);
- webview.loadURL(`data:${contentType},${encodeURIComponent(bodyWithBase)}`);
+ webview.loadURL(`data:text/html; charset=utf-8,${encodeURIComponent(bodyWithBase)}`);
}
};
if (webview) {
@@ -26,7 +25,7 @@ export const ResponseWebView: FC = ({ webpreferences, body, contentType,
webview.removeEventListener('dom-ready', handleDOMReady);
}
};
- }, [body, contentType, url]);
+ }, [body, url]);
return (