Add charset=UTF-8

This commit is contained in:
Ian Sanders
2024-05-14 14:08:35 -04:00
parent dfa71317ad
commit 56c4f10607
2 changed files with 2 additions and 2 deletions

View File

@@ -200,7 +200,7 @@ describe('mermaidAPI', () => {
it('sets src to base64 version of <body style="IFRAME_SVG_BODY_STYLE">svgCode<//body>', () => {
const base64encodedSrc = btoa('<body style="' + 'margin:0' + '">' + inputSvgCode + '</body>');
const expectedRegExp = new RegExp('src="data:text/html;base64,' + base64encodedSrc + '"');
const expectedRegExp = new RegExp('src="data:text/html;charset=UTF-8;base64,' + base64encodedSrc + '"');
const result = putIntoIFrame(inputSvgCode);
expect(result).toMatch(expectedRegExp);

View File

@@ -256,7 +256,7 @@ export const putIntoIFrame = (svgCode = '', svgElement?: D3Element): string => {
? svgElement.viewBox.baseVal.height + 'px'
: IFRAME_HEIGHT;
const base64encodedSrc = toBase64('<body style="' + IFRAME_BODY_STYLE + '">' + svgCode + '</body>');
return `<iframe style="width:${IFRAME_WIDTH};height:${height};${IFRAME_STYLES}" src="data:text/html;base64,${base64encodedSrc}" sandbox="${IFRAME_SANDBOX_OPTS}">
return `<iframe style="width:${IFRAME_WIDTH};height:${height};${IFRAME_STYLES}" src="data:text/html;charset=UTF-8;base64,${base64encodedSrc}" sandbox="${IFRAME_SANDBOX_OPTS}">
${IFRAME_NOT_SUPPORTED_MSG}
</iframe>`;
};