trusted types - loader should use trusted script url when using script tags, https://github.com/microsoft/vscode/issues/103699

This commit is contained in:
Johannes Rieken
2021-01-07 11:13:53 +01:00
parent de9e9c414e
commit 4aff4b9923

View File

@@ -99,6 +99,18 @@
preferScriptTags: useCustomProtocol
};
// use a trusted types policy when loading via script tags
if (loaderConfig.preferScriptTags) {
loaderConfig.trustedTypesPolicy = window.trustedTypes?.createPolicy('amdLoader', {
createScriptURL(value) {
if (value.startsWith(window.location.origin)) {
return value;
}
throw new Error(`Invalid script url: ${value}`);
}
});
}
// Enable loading of node modules:
// - sandbox: we list paths of webpacked modules to help the loader
// - non-sandbox: we signal that any module that does not begin with