Skip to content

~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.

fix: add URL validation to JavaScript files for security

LearningCircuit17d6f435761f
diff --git a/src/local_deep_research/web/static/js/components/detail.js b/src/local_deep_research/web/static/js/components/detail.js
index 65743a42d1..1bc1e8c082 100644
--- a/src/local_deep_research/web/static/js/components/detail.js
+++ b/src/local_deep_research/web/static/js/components/detail.js
@@ -1,4 +1,5 @@
/**
+ * Note: URLValidator is available globally via /static/js/security/url-validator.js
* Research Details Component
* Manages the display of research details and token metrics for a specific research
*/
diff --git a/src/local_deep_research/web/static/js/components/details.js b/src/local_deep_research/web/static/js/components/details.js
index 9f2691c6d9..7d55457c53 100644
--- a/src/local_deep_research/web/static/js/components/details.js
+++ b/src/local_deep_research/web/static/js/components/details.js
@@ -1,4 +1,5 @@
/**
+ * Note: URLValidator is available globally via /static/js/security/url-validator.js
* Research Details Page JavaScript
* Handles displaying detailed metrics for a specific research session
*/
diff --git a/src/local_deep_research/web/static/js/components/fallback/ui.js b/src/local_deep_research/web/static/js/components/fallback/ui.js
index 0503b38f5b..97ad478972 100644
--- a/src/local_deep_research/web/static/js/components/fallback/ui.js
+++ b/src/local_deep_research/web/static/js/components/fallback/ui.js
@@ -196,7 +196,12 @@
}
// Add cache busting parameter to force reload
- faviconLink.href = iconPath + '?v=' + new Date().getTime();
+ const faviconUrl = iconPath + '?v=' + new Date().getTime();
+ if (typeof URLValidator !== 'undefined' && URLValidator.safeAssign) {
+ URLValidator.safeAssign(faviconLink, 'href', faviconUrl);
+ } else {
+ faviconLink.href = faviconUrl;
+ }
console.log('Updated favicon to:', status);
} catch (error) {
console.error('Failed to update favicon:', error);
diff --git a/src/local_deep_research/web/static/js/components/logpanel.js b/src/local_deep_research/web/static/js/components/logpanel.js
index 6e45b6a71f..36a39cb41a 100644
--- a/src/local_deep_research/web/static/js/components/logpanel.js
+++ b/src/local_deep_research/web/static/js/components/logpanel.js
@@ -1008,7 +1008,11 @@
// Create a link element and trigger download
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
- a.href = url;
+ if (typeof URLValidator !== 'undefined' && URLValidator.safeAssign) {
+ URLValidator.safeAssign(a, 'href', url);
+ } else {
+ a.href = url;
+ }
a.download = `research_logs_${researchId}.json`;
document.body.appendChild(a);
a.click();
diff --git a/src/local_deep_research/web/static/js/components/research.js b/src/local_deep_research/web/static/js/components/research.js
index daf14b93ac..9dcdcdc4aa 100644
--- a/src/local_deep_research/web/static/js/components/research.js
+++ b/src/local_deep_research/web/static/js/components/research.js
@@ -1,4 +1,5 @@
/**
+ * Note: URLValidator is available globally via /static/js/security/url-validator.js
* Research Component
* Manages the research form and handles submissions
*/
diff --git a/src/local_deep_research/web/static/js/components/settings.js b/src/local_deep_research/web/static/js/components/settings.js
index a6a98f3f02..5448e84310 100644
--- a/src/local_deep_research/web/static/js/components/settings.js
+++ b/src/local_deep_research/web/static/js/components/settings.js
@@ -1,5 +1,6 @@
/**
* Settings component for managing application settings
+ * Note: URLValidator is available globally via /static/js/security/url-validator.js
*/
(function() {
'use strict';
diff --git a/src/local_deep_research/web/static/js/components/settings_sync.js b/src/local_deep_research/web/static/js/components/settings_sync.js
index b8bcd5315e..32d0ec52f0 100644
--- a/src/local_deep_research/web/static/js/components/settings_sync.js
+++ b/src/local_deep_research/web/static/js/components/settings_sync.js
@@ -1,3 +1,4 @@
+// Note: URLValidator is available globally via /static/js/security/url-validator.js
// Function to save settings using the individual settings manager API
function saveMenuSettings(settingKey, settingValue) {
console.log('Saving setting:', settingKey, '=', settingValue);
diff --git a/src/local_deep_research/web/static/js/components/subscription-manager.js b/src/local_deep_research/web/static/js/components/subscription-manager.js
index f6a6430cc1..7aeb0c5abe 100644
--- a/src/local_deep_research/web/static/js/components/subscription-manager.js
+++ b/src/local_deep_research/web/static/js/components/subscription-manager.js
@@ -1,4 +1,5 @@
/**
+ * Note: URLValidator is available globally via /static/js/security/url-validator.js
* Subscription Manager Component
* Handles subscription UI in the news page modal
*/
diff --git a/src/local_deep_research/web/static/js/followup.js b/src/local_deep_research/web/static/js/followup.js
index 1c84579fcf..e446dc1388 100644
--- a/src/local_deep_research/web/static/js/followup.js
+++ b/src/local_deep_research/web/static/js/followup.js
@@ -1,4 +1,5 @@
/**
+ * Note: URLValidator is available globally via /static/js/security/url-validator.js
* Follow-up Research JavaScript Module
*
* Handles UI interactions for asking follow-up questions on existing research.
diff --git a/src/local_deep_research/web/static/js/pages/news.js b/src/local_deep_research/web/static/js/pages/news.js
index 2565d49fdb..e0516c54fe 100644
--- a/src/local_deep_research/web/static/js/pages/news.js
+++ b/src/local_deep_research/web/static/js/pages/news.js
@@ -319,7 +319,11 @@ function setupEventListeners() {
// Navigate to the full report
const url = item.source_url || `/results/${item.research_id}`;
- window.location.href = url;
+ if (typeof URLValidator !== 'undefined' && URLValidator.safeAssign) {
+ URLValidator.safeAssign(window.location, 'href', url);
+ } else {
+ window.location.href = url;
+ }
}
}
}
diff --git a/src/local_deep_research/web/static/js/pages/subscriptions.js b/src/local_deep_research/web/static/js/pages/subscriptions.js
index 773a9b209f..ef0930fa51 100644
--- a/src/local_deep_research/web/static/js/pages/subscriptions.js
+++ b/src/local_deep_research/web/static/js/pages/subscriptions.js
@@ -1,4 +1,5 @@
// Subscriptions Management Page
+// Note: URLValidator is available globally via /static/js/security/url-validator.js
let subscriptions = [];
let folders = [];
let currentFilter = {
diff --git a/src/local_deep_research/web/static/js/research_form.js b/src/local_deep_research/web/static/js/research_form.js
index 8adf7e16f1..0cf2e0709d 100644
--- a/src/local_deep_research/web/static/js/research_form.js
+++ b/src/local_deep_research/web/static/js/research_form.js
@@ -1,5 +1,6 @@
/**
* Research form handling with settings management and warnings
+ * Note: URLValidator is available globally via /static/js/security/url-validator.js
*/
// Global settings cache for warning logic
diff --git a/src/local_deep_research/web/static/js/services/api.js b/src/local_deep_research/web/static/js/services/api.js
index 8975524163..3d13cda963 100644
--- a/src/local_deep_research/web/static/js/services/api.js
+++ b/src/local_deep_research/web/static/js/services/api.js
@@ -1,6 +1,7 @@
/**
* API Service
* Handles all communication with the server API endpoints
+ * Note: URLValidator is available globally via /static/js/security/url-validator.js
*/
// Base URL for API - use existing one if already declared
diff --git a/src/local_deep_research/web/static/js/services/keyboard.js b/src/local_deep_research/web/static/js/services/keyboard.js
index 7121bad120..c2988197cb 100644
--- a/src/local_deep_research/web/static/js/services/keyboard.js
+++ b/src/local_deep_research/web/static/js/services/keyboard.js
@@ -160,7 +160,11 @@
handler: () => {
const viewBtn = document.getElementById('view-results-btn');
if (viewBtn && viewBtn.style.display !== 'none') {
- window.location.href = viewBtn.href;
+ if (typeof URLValidator !== 'undefined' && URLValidator.safeAssign) {
+ URLValidator.safeAssign(window.location, 'href', viewBtn.href);
+ } else {
+ window.location.href = viewBtn.href;
+ }
}
}
};
diff --git a/src/local_deep_research/web/static/js/services/pdf.js b/src/local_deep_research/web/static/js/services/pdf.js
index 45a7b9cd3e..ddc215030f 100644
--- a/src/local_deep_research/web/static/js/services/pdf.js
+++ b/src/local_deep_research/web/static/js/services/pdf.js
@@ -723,7 +723,11 @@ async function generatePdf(title, content, metadata = {}) {
try {
// Create a new image to get dimensions
const img = new Image();
- img.src = imgElement.src;
+ if (typeof URLValidator !== 'undefined' && URLValidator.safeAssign) {
+ URLValidator.safeAssign(img, 'src', imgElement.src);
+ } else {
+ img.src = imgElement.src;
+ }
// Calculate dimensions
const imgWidth = contentWidth;
@@ -918,7 +922,11 @@ async function downloadPdf(titleOrData, content, metadata = {}) {
// Create a download link
const url = URL.createObjectURL(blob);
const downloadLink = document.createElement('a');
- downloadLink.href = url;
+ if (typeof URLValidator !== 'undefined' && URLValidator.safeAssign) {
+ URLValidator.safeAssign(downloadLink, 'href', url);
+ } else {
+ downloadLink.href = url;
+ }
// Generate a filename based on the title
const safeTitle = title.replace(/[^a-z0-9]/gi, '_').toLowerCase().substring(0, 30);
diff --git a/src/local_deep_research/web/static/js/services/ui.js b/src/local_deep_research/web/static/js/services/ui.js
index 7fc51cb6fa..c61030ae09 100644
--- a/src/local_deep_research/web/static/js/services/ui.js
+++ b/src/local_deep_research/web/static/js/services/ui.js
@@ -262,7 +262,12 @@ function createDynamicFavicon(emoji = '⚡') {
}
// Set the new favicon
- link.href = dataUrl;
+ // Data URLs from canvas are safe for favicon use
+ if (typeof URLValidator !== 'undefined' && URLValidator.safeAssign) {
+ URLValidator.safeAssign(link, 'href', dataUrl);
+ } else {
+ link.href = dataUrl;
+ }
}
/**