Skip to content

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

chore: added max size for the downloaded page, and max. timeout

Ilian Sapundshiev53b229f9dae9
diff --git a/src/renderer/hooks/IOActionsContextProvider.tsx b/src/renderer/hooks/IOActionsContextProvider.tsx
index 4cf36b64e..7057d0618 100644
--- a/src/renderer/hooks/IOActionsContextProvider.tsx
+++ b/src/renderer/hooks/IOActionsContextProvider.tsx
@@ -1089,11 +1089,17 @@ export const IOActionsContextProvider = ({
});
}
- /** Fetch a page's HTML, bypassing CORS/CSP via the main process on Electron. */
+ /**
+ * Fetch a page's HTML, bypassing CORS/CSP via the main process on Electron.
+ * Capped in size/time: the page is untrusted and fetched whole into memory.
+ */
function fetchPageHtml(url: string): Promise<string> {
if (AppConfig.isElectron) {
return window.electronIO.ipcRenderer
- .invoke('fetchUrlBuffer', url)
+ .invoke('fetchUrlBuffer', url, {
+ maxBytes: 50 * 1024 * 1024,
+ timeoutMs: 60000,
+ })
.then((res) => {
if (res?.error) {
throw new Error(res.error);