~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(security): sanitize user input to prevent XSS vulnerabilities (#1862)
LearningCircuit15f0f002cb21
diff --git a/src/local_deep_research/web/static/js/collection_create.js b/src/local_deep_research/web/static/js/collection_create.jsindex eadd18ded5..d8acbcd723 100644--- a/src/local_deep_research/web/static/js/collection_create.js+++ b/src/local_deep_research/web/static/js/collection_create.js@@ -3,6 +3,10 @@* Handles creation of new collections*/+// Inline fallback for XSS protection if xss-protection.js fails to load+// Using 'var' allows redeclaration if this script is loaded with other scripts that define the same fallback+var escapeHtmlFallback = escapeHtmlFallback || ((str) => String(str).replace(/[&<>"']/g, (m) => ({'&':'&','<':'<','>':'>','"':'"',"'":'''})[m]));+// Use existing URLS configuration from config/urls.js// Collection create endpoint is now available as URLS.LIBRARY_API.COLLECTION_CREATE@@ -135,8 +139,9 @@ function showCreateResults(data) {html += '<h4 style="margin: 0 0 0.5rem 0;"><i class="fas fa-check-circle"></i> Collection Created!</h4>';if (data.collection && data.collection.id) {+ const escapeHtml = window.escapeHtml || escapeHtmlFallback;html += `<p><strong>Collection created successfully!</strong></p>`;- html += '<p>Your collection ID is: <strong>' + data.collection.id + '</strong></p>';+ html += '<p>Your collection ID is: <strong>' + escapeHtml(data.collection.id) + '</strong></p>';html += '<div style="margin-top: 1rem;">';html += `<a href="/library/collections/${data.collection.id}" class="ldr-btn-collections ldr-btn-collections-primary">`;html += '<i class="fas fa-folder-open"></i> View Collection';@@ -170,10 +175,11 @@ function showCreateResults(data) {*/function showError(message) {const resultsDiv = document.getElementById('create-results');+ const escapeHtml = window.escapeHtml || escapeHtmlFallback;const html = `<div class="ldr-alert ldr-alert-danger" style="padding: 1rem; border-radius: 8px; margin-bottom: 1rem;"><h4 style="margin: 0 0 0.5rem 0;"><i class="fas fa-exclamation-triangle"></i> Creation Error</h4>- <p>${message}</p>+ <p>${escapeHtml(message)}</p><div style="margin-top: 1rem;"><a href="/library/collections" class="ldr-btn-collections ldr-btn-collections-primary">Back to Collections</a></div>diff --git a/src/local_deep_research/web/static/js/deletion/delete_manager.js b/src/local_deep_research/web/static/js/deletion/delete_manager.jsindex 9c2eadb980..7dc9904732 100644--- a/src/local_deep_research/web/static/js/deletion/delete_manager.js+++ b/src/local_deep_research/web/static/js/deletion/delete_manager.js@@ -12,6 +12,10 @@* URLValidator is not needed here as all fetch() calls are to internal paths.*/+// Inline fallback for XSS protection if xss-protection.js fails to load+// Using 'var' allows redeclaration if this script is loaded with other scripts that define the same fallback+var escapeHtmlFallback = escapeHtmlFallback || ((str) => String(str).replace(/[&<>"']/g, (m) => ({'&':'&','<':'<','>':'>','"':'"',"'":'''})[m]));+// API Endpointsconst DELETE_API = {DOCUMENT: '/library/api/document/',@@ -594,9 +598,10 @@ function showNotification(type, message) {const toastEl = document.createElement('div');toastEl.className = `toast align-items-center text-white bg-${type === 'error' ? 'danger' : type}`;toastEl.setAttribute('role', 'alert');+ const escapeHtml = window.escapeHtml || escapeHtmlFallback;toastEl.innerHTML = `<div class="d-flex">- <div class="toast-body">${message}</div>+ <div class="toast-body">${escapeHtml(message)}</div><button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button></div>`;diff --git a/src/local_deep_research/web/static/js/services/socket.js b/src/local_deep_research/web/static/js/services/socket.jsindex 2ee1bdee51..b1af246d37 100644--- a/src/local_deep_research/web/static/js/services/socket.js+++ b/src/local_deep_research/web/static/js/services/socket.js@@ -3,6 +3,10 @@* Manages WebSocket communication using Socket.IO*/+// Inline fallback for XSS protection if xss-protection.js fails to load+// Using 'var' allows redeclaration if this script is loaded with other scripts that define the same fallback+var escapeHtmlFallback = escapeHtmlFallback || ((str) => String(str).replace(/[&<>"']/g, (m) => ({'&':'&','<':'<','>':'>','"':'"',"'":'''})[m]));+window.socket = (function() {let socket = null;let researchEventHandlers = {};@@ -768,7 +772,9 @@ window.socket = (function() {const emptyMessage = logContainer.querySelector('.ldr-empty-log-message');if (visibleEntries.length === 0 && !emptyMessage) {- logContainer.innerHTML = `<div class="empty-log-message">No ${type === 'all' ? '' : type + ' '}logs available.</div>` + logContainer.innerHTML;+ const escapeHtml = window.escapeHtml || escapeHtmlFallback;+ const typeText = type === 'all' ? '' : escapeHtml(type) + ' ';+ logContainer.innerHTML = `<div class="empty-log-message">No ${typeText}logs available.</div>` + logContainer.innerHTML;} else if (visibleEntries.length > 0 && emptyMessage) {emptyMessage.remove();}@@ -922,11 +928,12 @@ if (!window.addConsoleLog) {entry.dataset.logType = level.toLowerCase();entry.classList.add(`log-${level.toLowerCase()}`);- // Create log content+ // Create log content with XSS protection+ const escapeHtml = window.escapeHtml || escapeHtmlFallback;entry.innerHTML = `<span class="log-timestamp">${new Date().toLocaleTimeString()}</span>- <span class="log-badge ${level}">${level.charAt(0).toUpperCase() + level.slice(1)}</span>- <span class="log-message">${message}</span>+ <span class="log-badge ${escapeHtml(level)}">${escapeHtml(level.charAt(0).toUpperCase() + level.slice(1))}</span>+ <span class="log-message">${escapeHtml(message)}</span>`;}