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.

chore(js): drop dead escapeHtml fallbacks (#4732)

LearningCircuit3cf71ac2e054
diff --git a/src/local_deep_research/web/static/js/collection_upload.js b/src/local_deep_research/web/static/js/collection_upload.js
index 1576bdf278..e411c8a101 100644
--- a/src/local_deep_research/web/static/js/collection_upload.js
+++ b/src/local_deep_research/web/static/js/collection_upload.js
@@ -6,14 +6,9 @@
// Use existing URLS configuration from config/urls.js
// Collection upload endpoint is now available as URLS.LIBRARY_API.COLLECTION_UPLOAD
// safeFetch (with URLValidator) is now provided by utils/safe-fetch.js loaded in base.html
-
-// Prefer the full escapeHtml from xss-protection.js; inline fallback if it hasn't loaded yet
-// bearer:disable javascript_lang_manual_html_sanitization
-const escapeHtml = window.escapeHtml || function(str) {
- return String(str).replace(/[&<>"']/g, function(m) {
- return {'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[m];
- });
-};
+// escapeHtml is the canonical window.escapeHtml from security/xss-protection.js
+// (loaded first via base.html). Do NOT reintroduce a local fallback — it would
+// be weaker (e.g. not escape "/") and risk a duplicate-const SyntaxError (#3706).
// Store selected files globally to avoid losing them
let selectedFiles = [];
diff --git a/src/local_deep_research/web/static/js/collections_manager.js b/src/local_deep_research/web/static/js/collections_manager.js
index be43fb5fa4..14b2e0e7cc 100644
--- a/src/local_deep_research/web/static/js/collections_manager.js
+++ b/src/local_deep_research/web/static/js/collections_manager.js
@@ -7,6 +7,9 @@
let collections = [];
// safeFetch is now provided by utils/safe-fetch.js loaded in base.html
+// escapeHtml is the canonical window.escapeHtml from security/xss-protection.js
+// (loaded first via base.html). Do NOT reintroduce a local fallback — it would
+// be weaker (e.g. not escape "/") and risk a duplicate-const SyntaxError (#3706).
/**
* Initialize the page
@@ -141,15 +144,6 @@ function renderCollections() {
`).join('');
}
-// Prefer the full escapeHtml from xss-protection.js; inline fallback if it hasn't loaded yet
-// bearer:disable javascript_lang_manual_html_sanitization
-const escapeHtml = window.escapeHtml || function(str) {
- return String(str).replace(/[&<>"']/g, function(m) {
- return {'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[m];
- });
-};
-
-
/**
* Show success message
*/
diff --git a/src/local_deep_research/web/static/js/components/history_search.js b/src/local_deep_research/web/static/js/components/history_search.js
index 32603f63c9..a26790886b 100644
--- a/src/local_deep_research/web/static/js/components/history_search.js
+++ b/src/local_deep_research/web/static/js/components/history_search.js
@@ -10,14 +10,6 @@
(function() {
// URL validation: isSafeUrl provided by SemanticSearch (semantic_search.js)
-// Use shared escapeHtml from xss-protection.js (loaded via base.html),
-// with a safe fallback if not available.
-const escapeHtml = window.escapeHtml || function(text) {
- if (text === null || text === undefined) return '';
- const div = document.createElement('div');
- div.textContent = String(text);
- return div.innerHTML;
-};
// State
let isIndexing = false;
diff --git a/src/local_deep_research/web/static/js/embedding_settings.js b/src/local_deep_research/web/static/js/embedding_settings.js
index 2835edd930..7a80a1275c 100644
--- a/src/local_deep_research/web/static/js/embedding_settings.js
+++ b/src/local_deep_research/web/static/js/embedding_settings.js
@@ -10,6 +10,9 @@ let originalValues = {};
let autoSaveListenersAttached = false;
// safeFetch is now provided by utils/safe-fetch.js loaded in base.html
+// escapeHtml is the canonical window.escapeHtml from security/xss-protection.js
+// (loaded first via base.html). Do NOT reintroduce a local fallback — it would
+// be weaker (e.g. not escape "/") and risk a duplicate-const SyntaxError (#3706).
/**
* Initialize the page
@@ -915,15 +918,6 @@ function showError(message) {
}, 5000);
}
-// Prefer the full escapeHtml from xss-protection.js; inline fallback if it hasn't loaded yet
-// bearer:disable javascript_lang_manual_html_sanitization
-const escapeHtml = window.escapeHtml || function(str) {
- return String(str).replace(/[&<>"']/g, function(m) {
- return {'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[m];
- });
-};
-
-
/**
* Toggle Ollama-specific fields (URL, num_ctx) based on selected provider
*/