Skip to content

TagSpaces is an offline, open source, document manager with tagging support

chore: added additional check on will-attach-webview

Ilian Sapundshievce40db9ea41e
diff --git a/src/main/main.ts b/src/main/main.ts
index 63e7d177d..513774ff5 100644
--- a/src/main/main.ts
+++ b/src/main/main.ts
@@ -593,6 +593,19 @@ app.on('web-contents-created', (event, contents) => {
event.preventDefault();
}
});
+
+ contents.on('will-attach-webview', (event, webPreferences, params) => {
+ // Strip away preload scripts if unused or verify their location is legitimate
+ delete webPreferences.preload;
+
+ // Disable Node.js integration
+ webPreferences.nodeIntegration = false;
+
+ // Verify URL being loaded
+ if (!params.src.startsWith('file://')) {
+ event.preventDefault();
+ }
+ });
});
// --- Startup ---