Skip to content

Commit

Permalink
use default tt policy to workaround electron webview innerHTML-usage, #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jan 7, 2021
1 parent d5fc23c commit a9dc6d2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/vs/code/electron-browser/workbench/workbench.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@
}
);

// add default trustedTypes-policy for logging and to workaround
// lib/platform limitations
window.trustedTypes?.createPolicy('default', {
createHTML(value) {
// see https://github.com/electron/electron/issues/27211
// Electron webviews use a static innerHTML default value and
// that isn't trusted. We use a default policy to check for the
// exact value of that innerHTML-string and only allow that.
if (value === '<!DOCTYPE html><style type="text/css">:host { display: flex; }</style>') {
return value;
}
// throw new Error('INVALID html usage' + value);
console.trace('UNTRUSTED html usage, default trusted types policy should NEVER be reached');
return value;
}
});

//region Helpers

Expand Down

0 comments on commit a9dc6d2

Please sign in to comment.