From e7c201288c3d29803f7885aad8373f7ebc540256 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Mon, 25 Jan 2021 17:08:58 +0100 Subject: [PATCH] chore: enable Trusted Types in default app (#27453) --- default_app/index.html | 1 + default_app/preload.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/default_app/index.html b/default_app/index.html index a4edefea906..5ac92e4fb8f 100644 --- a/default_app/index.html +++ b/default_app/index.html @@ -2,6 +2,7 @@ Electron + diff --git a/default_app/preload.ts b/default_app/preload.ts index b18130a1d0f..c446398912a 100644 --- a/default_app/preload.ts +++ b/default_app/preload.ts @@ -1,10 +1,15 @@ import { ipcRenderer, contextBridge } from 'electron'; +const policy = window.trustedTypes.createPolicy('electron-default-app', { + // we trust the SVG contents + createHTML: input => input +}); + async function getOcticonSvg (name: string) { try { const response = await fetch(`octicon/${name}.svg`); const div = document.createElement('div'); - div.innerHTML = await response.text(); + div.innerHTML = policy.createHTML(await response.text()); return div; } catch { return null;