From 69c9e8cc0859d6d66350e099d5477db1fffc4ae1 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Sun, 23 Jun 2024 16:16:53 +0530 Subject: [PATCH] Disable CSP in Khoj Obsidian as it interferes with Obsidian functionality The Khoj CSP interferes with other Obsidian features and plugins as CSP is applied page wide. For now chat message sanitization via Dompurify should suffice. Enable CSP when can scope it to only the Khoj Obsidian plugin. --- src/interface/obsidian/src/chat_view.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/interface/obsidian/src/chat_view.ts b/src/interface/obsidian/src/chat_view.ts index 0e91d4b9..d6b7f76f 100644 --- a/src/interface/obsidian/src/chat_view.ts +++ b/src/interface/obsidian/src/chat_view.ts @@ -96,8 +96,9 @@ export class KhojChatView extends KhojPaneView { const objectSrc = `object-src 'none';`; const csp = `${defaultSrc} ${scriptSrc} ${connectSrc} ${styleSrc} ${imgSrc} ${childSrc} ${objectSrc}`; - // Add CSP meta tag to the Khoj Chat modal - document.head.createEl("meta", { attr: { "http-equiv": "Content-Security-Policy", "content": `${csp}` } }); + // WARNING: CSP DISABLED for now as it breaks other Obsidian plugins. Enable when can scope CSP to only Khoj plugin. + // CSP meta tag for the Khoj Chat modal + // document.head.createEl("meta", { attr: { "http-equiv": "Content-Security-Policy", "content": `${csp}` } }); // Create area for chat logs let chatBodyEl = contentEl.createDiv({ attr: { id: "khoj-chat-body", class: "khoj-chat-body" } });