~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: Address all CodeQL security vulnerabilities
LearningCircuitc97745b8721c
diff --git a/src/local_deep_research/news/flask_api.py b/src/local_deep_research/news/flask_api.pyindex b1d7171bef..f71286bb45 100644--- a/src/local_deep_research/news/flask_api.py+++ b/src/local_deep_research/news/flask_api.py@@ -15,6 +15,32 @@ from ..database.session_context import get_user_db_sessionfrom ..utilities.get_settings_manager import get_settings_manager+def safe_error_message(e: Exception, context: str = "") -> str:+ """+ Return a safe error message that doesn't expose internal details.++ Args:+ e: The exception+ context: Optional context about what was being attempted++ Returns:+ A generic error message safe for external users+ """+ # Log the actual error for debugging+ logger.exception(f"Error in {context}")++ # Return generic messages based on exception type+ if isinstance(e, ValueError):+ return "Invalid input provided"+ elif isinstance(e, KeyError):+ return "Required data missing"+ elif isinstance(e, TypeError):+ return "Invalid data format"+ else:+ # Generic message for production+ return f"An error occurred{f' while {context}' if context else ''}"++# Create Blueprint - no url_prefix here since parent blueprint already has /newsnews_api_bp = Blueprint("news_api", __name__, url_prefix="/api")@@ -93,8 +119,12 @@ def get_news_feed() -> Dict[str, Any]:return jsonify(result)except Exception as e:- logger.exception("Error getting news feed")- return jsonify({"error": str(e), "news_items": []}), 500+ return jsonify(+ {+ "error": safe_error_message(e, "getting news feed"),+ "news_items": [],+ }+ ), 500@news_api_bp.route("/subscribe", methods=["POST"])@@ -167,10 +197,13 @@ def create_subscription() -> Dict[str, Any]:return jsonify(result)except ValueError as e:- return jsonify({"error": str(e)}), 400+ return jsonify(+ {"error": safe_error_message(e, "creating subscription")}+ ), 400except Exception as e:- logger.exception("Error creating subscription")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "creating subscription")}+ ), 500@news_api_bp.route("/vote", methods=["POST"])@@ -208,12 +241,13 @@ def vote_on_news() -> Dict[str, Any]:except ValueError as e:error_msg = str(e)if "not found" in error_msg.lower():- return jsonify({"error": error_msg}), 404+ return jsonify({"error": "Resource not found"}), 404else:- return jsonify({"error": error_msg}), 400+ return jsonify(+ {"error": safe_error_message(e, "submitting vote")}+ ), 400except Exception as e:- logger.exception("Error submitting vote")- return jsonify({"error": str(e)}), 500+ return jsonify({"error": safe_error_message(e, "submitting vote")}), 500@news_api_bp.route("/feedback/<card_id>", methods=["POST"])@@ -248,14 +282,17 @@ def submit_feedback(card_id: str) -> Dict[str, Any]:except ValueError as e:error_msg = str(e)if "not found" in error_msg.lower():- return jsonify({"error": error_msg}), 404+ return jsonify({"error": "Resource not found"}), 404elif "must be" in error_msg.lower():- return jsonify({"error": error_msg}), 400+ return jsonify({"error": "Invalid input value"}), 400else:- return jsonify({"error": error_msg}), 400+ return jsonify(+ {"error": safe_error_message(e, "submitting feedback")}+ ), 400except Exception as e:- logger.exception("Error submitting feedback")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "submitting feedback")}+ ), 500@news_api_bp.route("/research/<card_id>", methods=["POST"])@@ -277,8 +314,9 @@ def research_news_item(card_id: str) -> Dict[str, Any]:return jsonify(result)except Exception as e:- logger.exception("Error researching news item")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "researching news item")}+ ), 500@news_api_bp.route("/subscriptions/current", methods=["GET"])@@ -298,8 +336,9 @@ def get_current_user_subscriptions() -> Dict[str, Any]:return jsonify(result)except Exception as e:- logger.exception("Error getting subscriptions")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "getting subscriptions")}+ ), 500@news_api_bp.route("/subscriptions/<subscription_id>", methods=["GET"])@@ -316,8 +355,9 @@ def get_subscription(subscription_id: str) -> Dict[str, Any]:return jsonify(subscription)except Exception as e:- logger.exception("Error getting subscription")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "getting subscription")}+ ), 500@news_api_bp.route("/subscriptions/<subscription_id>", methods=["PUT"])@@ -368,8 +408,9 @@ def update_subscription(subscription_id: str) -> Dict[str, Any]:return jsonify(result)except Exception as e:- logger.exception("Error updating subscription")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "updating subscription")}+ ), 500@news_api_bp.route("/subscriptions/<subscription_id>", methods=["DELETE"])@@ -391,8 +432,9 @@ def delete_subscription(subscription_id: str) -> Dict[str, Any]:return jsonify({"error": "Subscription not found"}), 404except Exception as e:- logger.exception("Error deleting subscription")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "deleting subscription")}+ ), 500@news_api_bp.route("/subscriptions/<subscription_id>/run", methods=["POST"])@@ -491,8 +533,9 @@ def run_subscription_now(subscription_id: str) -> Dict[str, Any]:), response.status_codeexcept Exception as e:- logger.exception("Error running subscription")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "running subscription")}+ ), 500@news_api_bp.route("/subscriptions/<subscription_id>/history", methods=["GET"])@@ -506,8 +549,9 @@ def get_subscription_history(subscription_id: str) -> Dict[str, Any]:result = api.get_subscription_history(subscription_id, limit)return jsonify(result)except Exception as e:- logger.exception("Error getting subscription history")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "getting subscription history")}+ ), 500@news_api_bp.route("/preferences", methods=["POST"])@@ -529,8 +573,9 @@ def save_preferences() -> Dict[str, Any]:return jsonify(result)except Exception as e:- logger.exception("Error saving preferences")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "saving preferences")}+ ), 500@news_api_bp.route("/categories", methods=["GET"])@@ -543,8 +588,9 @@ def get_categories() -> Dict[str, Any]:return jsonify(result)except Exception as e:- logger.exception("Error getting categories")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "getting categories")}+ ), 500@news_api_bp.route("/scheduler/status", methods=["GET"])@@ -613,8 +659,9 @@ def get_scheduler_status() -> Dict[str, Any]:return jsonify(status)except Exception as e:- logger.exception("Error getting scheduler status")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "getting scheduler status")}+ ), 500@news_api_bp.route("/scheduler/start", methods=["POST"])@@ -647,8 +694,9 @@ def start_scheduler() -> Dict[str, Any]:)except Exception as e:- logger.exception("Error starting scheduler")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "starting scheduler")}+ ), 500@news_api_bp.route("/scheduler/stop", methods=["POST"])@@ -674,8 +722,9 @@ def stop_scheduler() -> Dict[str, Any]:return jsonify({"message": "No scheduler instance found"}), 404except Exception as e:- logger.exception("Error stopping scheduler")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "stopping scheduler")}+ ), 500@news_api_bp.route("/scheduler/check-now", methods=["POST"])@@ -731,8 +780,9 @@ def check_subscriptions_now() -> Dict[str, Any]:)except Exception as e:- logger.exception("Error checking subscriptions")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "checking subscriptions")}+ ), 500@news_api_bp.route("/scheduler/cleanup-now", methods=["POST"])@@ -764,8 +814,9 @@ def trigger_cleanup() -> Dict[str, Any]:)except Exception as e:- logger.exception("Error triggering cleanup")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "triggering cleanup")}+ ), 500@news_api_bp.route("/scheduler/users", methods=["GET"])@@ -783,8 +834,9 @@ def get_active_users() -> Dict[str, Any]:)except Exception as e:- logger.exception("Error getting active users")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "getting active users")}+ ), 500@news_api_bp.route("/scheduler/stats", methods=["GET"])@@ -845,8 +897,9 @@ def scheduler_stats() -> Dict[str, Any]:return jsonify(debug_info)except Exception as e:- logger.exception("Error in debug scheduler")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "getting scheduler stats")}+ ), 500@news_api_bp.route("/check-overdue", methods=["POST"])@@ -990,7 +1043,9 @@ def check_overdue_subscriptions():{"id": str(sub.id),"name": sub.name or sub.query_or_topic[:50],- "error": str(e),+ "error": safe_error_message(+ e, "running subscription"+ ),})@@ -1004,8 +1059,9 @@ def check_overdue_subscriptions():)except Exception as e:- logger.exception("Error checking overdue subscriptions")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "checking overdue subscriptions")}+ ), 500# Folder and subscription management routes@@ -1023,8 +1079,7 @@ def get_folders():return jsonify([folder.to_dict() for folder in folders])except Exception as e:- logger.exception("Error getting folders")- return jsonify({"error": str(e)}), 500+ return jsonify({"error": safe_error_message(e, "getting folders")}), 500@news_api_bp.route("/subscription/folders", methods=["POST"])@@ -1059,8 +1114,7 @@ def create_folder():return jsonify(folder.to_dict()), 201except Exception as e:- logger.exception("Error creating folder")- return jsonify({"error": str(e)}), 500+ return jsonify({"error": safe_error_message(e, "creating folder")}), 500@news_api_bp.route("/subscription/folders/<folder_id>", methods=["PUT"])@@ -1080,8 +1134,7 @@ def update_folder(folder_id):return jsonify(folder.to_dict())except Exception as e:- logger.exception("Error updating folder")- return jsonify({"error": str(e)}), 500+ return jsonify({"error": safe_error_message(e, "updating folder")}), 500@news_api_bp.route("/subscription/folders/<folder_id>", methods=["DELETE"])@@ -1101,8 +1154,7 @@ def delete_folder(folder_id):return jsonify({"status": "deleted"}), 200except Exception as e:- logger.exception("Error deleting folder")- return jsonify({"error": str(e)}), 500+ return jsonify({"error": safe_error_message(e, "deleting folder")}), 500@news_api_bp.route("/subscription/subscriptions/organized", methods=["GET"])@@ -1124,8 +1176,9 @@ def get_subscriptions_organized():return jsonify(result)except Exception as e:- logger.exception("Error getting organized subscriptions")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "getting organized subscriptions")}+ ), 500@news_api_bp.route(@@ -1186,8 +1239,9 @@ def update_subscription_folder(subscription_id):# Force reload: v2except Exception as e:- logger.exception("Error updating subscription")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "updating subscription")}+ ), 500@news_api_bp.route("/subscription/stats", methods=["GET"])@@ -1204,19 +1258,18 @@ def get_subscription_stats():return jsonify(stats)except Exception as e:- logger.exception("Error getting stats")- return jsonify({"error": str(e)}), 500+ return jsonify({"error": safe_error_message(e, "getting stats")}), 500# Error handlers@news_api_bp.errorhandler(400)def bad_request(e):- return jsonify({"error": str(e)}), 400+ return jsonify({"error": "Bad request"}), 400@news_api_bp.errorhandler(404)def not_found(e):- return jsonify({"error": str(e)}), 404+ return jsonify({"error": "Resource not found"}), 404@news_api_bp.errorhandler(500)@@ -1259,8 +1312,9 @@ def get_search_history():)except Exception as e:- logger.exception("Error getting search history")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "getting search history")}+ ), 500@news_api_bp.route("/search-history", methods=["POST"])@@ -1301,8 +1355,9 @@ def add_search_history():return jsonify({"status": "success", "id": search_history.id})except Exception as e:- logger.exception("Error adding search history")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "adding search history")}+ ), 500@news_api_bp.route("/search-history", methods=["DELETE"])@@ -1333,8 +1388,9 @@ def clear_search_history():return jsonify({"status": "success"})except Exception as e:- logger.exception("Error clearing search history")- return jsonify({"error": str(e)}), 500+ return jsonify(+ {"error": safe_error_message(e, "clearing search history")}+ ), 500@news_api_bp.route("/debug", methods=["GET"])@@ -1345,5 +1401,4 @@ def debug_database():result = api.debug_research_items(user_id)return jsonify(result)except Exception as e:- logger.exception("Error in debug endpoint")- return jsonify({"error": str(e)}), 500+ return jsonify({"error": safe_error_message(e, "debug endpoint")}), 500diff --git a/src/local_deep_research/web/static/js/pages/news.js b/src/local_deep_research/web/static/js/pages/news.jsindex 4880eb7d25..43539cbeea 100644--- a/src/local_deep_research/web/static/js/pages/news.js+++ b/src/local_deep_research/web/static/js/pages/news.js@@ -1,5 +1,27 @@// News Page JavaScript - Following LDR patterns+// HTML escaping function to prevent XSS+function escapeHtml(unsafe) {+ if (unsafe === null || unsafe === undefined) return '';+ return String(unsafe)+ .replace(/&/g, "&")+ .replace(/</g, "<")+ .replace(/>/g, ">")+ .replace(/"/g, """)+ .replace(/'/g, "'");+}++// Escape attributes for use in HTML attributes (onclick, etc)+function escapeAttr(unsafe) {+ if (unsafe === null || unsafe === undefined) return '';+ return String(unsafe)+ .replace(/\\/g, "\\\\")+ .replace(/'/g, "\\'")+ .replace(/"/g, '\\"')+ .replace(/\n/g, "\\n")+ .replace(/\r/g, "\\r");+}+// Global state// No anonymous users allowed - authentication requiredlet currentUser = null;@@ -378,11 +400,11 @@ async function performAdvancedNewsSearch(query, strategy = 'source-based', model<div class="news-header"><h2 class="news-title"><i class="bi bi-hourglass-split spinning"></i>- Analyzing: "${query.substring(0, 60)}..."+ Analyzing: "${escapeHtml(query.substring(0, 60))}..."</h2></div><div class="news-meta">- <span><i class="bi bi-info-circle"></i> Research ID: ${data.research_id}</span>+ <span><i class="bi bi-info-circle"></i> Research ID: ${escapeHtml(data.research_id)}</span><span><i class="bi bi-clock"></i> Started just now</span></div><div class="news-summary">@@ -741,8 +763,8 @@ function renderNewsItems(searchQuery = null) {if (itemsToRender.length === 0) {// Build filter status messagelet filterMessage = [];- if (searchQuery) filterMessage.push(`search: "${searchQuery}"`);- if (activeTopicFilter) filterMessage.push(`topic: ${activeTopicFilter}`);+ if (searchQuery) filterMessage.push(`search: "${escapeHtml(searchQuery)}"`);+ if (activeTopicFilter) filterMessage.push(`topic: ${escapeHtml(activeTopicFilter)}`);if (activeTimeFilter !== 'all') filterMessage.push(`time: ${activeTimeFilter}`);if (activeImpactThreshold > 0) filterMessage.push(`impact ≥ ${activeImpactThreshold}`);@@ -824,7 +846,7 @@ function renderNewsItems(searchQuery = null) {let topicsHtml = '';if (item.topics && item.topics.length > 0) {const topicTags = item.topics.map(topic =>- `<span class="topic-tag" data-topic="${topic.replace(/"/g, '"')}" title="Click to filter by ${topic}">${topic}</span>`+ `<span class="topic-tag" data-topic="${escapeHtml(topic)}" title="Click to filter by ${escapeHtml(topic)}">${escapeHtml(topic)}</span>`).join('');topicsHtml = `<div class="news-topics">${topicTags}</div>`;}@@ -832,12 +854,12 @@ function renderNewsItems(searchQuery = null) {const isExpanded = expandedNewsIds.has(item.id);return `- <div class="news-item priority-${priorityClass} ${newClasses} ${readClasses} is-expanded" data-news-id="${item.id}">+ <div class="news-item priority-${priorityClass} ${newClasses} ${readClasses} is-expanded" data-news-id="${escapeHtml(item.id)}">${isNew ? '<span class="new-indicator">New</span>' : ''}<div class="news-item-header">- <div class="news-headline">${item.headline}</div>+ <div class="news-headline">${escapeHtml(item.headline)}</div><div class="news-actions-menu">- <button class="btn btn-sm btn-ghost" onclick="toggleReadStatus('${item.id}')" title="${isRead ? 'Mark as unread' : 'Mark as read'}">+ <button class="btn btn-sm btn-ghost" onclick="toggleReadStatus('${escapeAttr(item.id)}')" title="${isRead ? 'Mark as unread' : 'Mark as read'}"><i class="bi ${isRead ? 'bi-envelope-open' : 'bi-envelope'}"></i></button><div class="dropdown">@@ -845,20 +867,20 @@ function renderNewsItems(searchQuery = null) {<i class="bi bi-three-dots-vertical"></i></button><ul class="dropdown-menu dropdown-menu-end">- <li><a class="dropdown-item" href="#" onclick="shareNews('${item.id}'); return false;">+ <li><a class="dropdown-item" href="#" onclick="shareNews('${escapeAttr(item.id)}'); return false;"><i class="bi bi-share"></i> Share</a></li>- <li><a class="dropdown-item" href="#" onclick="copyNewsLink('${item.id}'); return false;">+ <li><a class="dropdown-item" href="#" onclick="copyNewsLink('${escapeAttr(item.id)}'); return false;"><i class="bi bi-link-45deg"></i> Copy Link</a></li>- <li><a class="dropdown-item" href="#" onclick="exportToMarkdown('${item.id}'); return false;">+ <li><a class="dropdown-item" href="#" onclick="exportToMarkdown('${escapeAttr(item.id)}'); return false;"><i class="bi bi-markdown"></i> Export as Markdown</a></li><li><hr class="dropdown-divider"></li>- <li><a class="dropdown-item" href="#" onclick="hideNewsItem('${item.id}'); return false;">+ <li><a class="dropdown-item" href="#" onclick="hideNewsItem('${escapeAttr(item.id)}'); return false;"><i class="bi bi-eye-slash"></i> Hide this item</a></li>- <li><a class="dropdown-item text-danger" href="#" onclick="reportIssue('${item.id}'); return false;">+ <li><a class="dropdown-item text-danger" href="#" onclick="reportIssue('${escapeAttr(item.id)}'); return false;"><i class="bi bi-flag"></i> Report issue</a></li></ul>@@ -866,7 +888,7 @@ function renderNewsItems(searchQuery = null) {</div></div><div class="news-meta">- <span class="news-category">${item.category || 'General'}</span>+ <span class="news-category">${escapeHtml(item.category || 'General')}</span><span class="impact-indicator">Impact:<div class="impact-bar">@@ -881,10 +903,10 @@ function renderNewsItems(searchQuery = null) {${renderSourceLinks(item.links)}<div class="news-actions"><div class="vote-buttons">- <button class="vote-btn" onclick="vote('${item.id}', 'up')">+ <button class="vote-btn" onclick="vote('${escapeAttr(item.id)}', 'up')"><i class="fas fa-thumbs-up"></i> ${item.upvotes || 0}</button>- <button class="vote-btn" onclick="vote('${item.id}', 'down')">+ <button class="vote-btn" onclick="vote('${escapeAttr(item.id)}', 'down')"><i class="fas fa-thumbs-down"></i> ${item.downvotes || 0}</button></div>@@ -892,7 +914,7 @@ function renderNewsItems(searchQuery = null) {<a href="${item.source_url || `/results/${item.research_id}`}" class="btn btn-primary btn-sm"><i class="fas fa-file-alt"></i> View Full Report</a>- <button class="btn btn-secondary btn-sm save-btn" onclick="toggleSaveItem('${item.id}')" title="${savedNewsIds.has(item.id) ? 'Remove from saved' : 'Save for later'}">+ <button class="btn btn-secondary btn-sm save-btn" onclick="toggleSaveItem('${escapeAttr(item.id)}')" title="${savedNewsIds.has(item.id) ? 'Remove from saved' : 'Save for later'}"><i class="${savedNewsIds.has(item.id) ? 'bi bi-bookmark-fill' : 'bi bi-bookmark'}"></i></button>${item.query ? `<button class="btn btn-outline-primary btn-sm" onclick="createSubscriptionFromItem('${item.id}')" title="Create subscription from this search">@@ -1416,7 +1438,7 @@ function updateActiveTopicUI() {filterBar.innerHTML = `<div class="filter-info"><i class="bi bi-funnel-fill"></i>- Filtering by topic: <strong>${activeTopicFilter}</strong>+ Filtering by topic: <strong>${escapeHtml(activeTopicFilter)}</strong><button class="btn btn-sm btn-link" onclick="clearTopicFilter()"><i class="bi bi-x-circle"></i> Clear filter</button>@@ -1507,10 +1529,10 @@ function updateFilterStatusBar() {let filterBadges = [];if (activeTopicFilter) {- filterBadges.push(`<span class="filter-badge">Topic: ${activeTopicFilter}</span>`);+ filterBadges.push(`<span class="filter-badge">Topic: ${escapeHtml(activeTopicFilter)}</span>`);}if (activeTimeFilter !== 'all') {- filterBadges.push(`<span class="filter-badge">Time: ${activeTimeFilter}</span>`);+ filterBadges.push(`<span class="filter-badge">Time: ${escapeHtml(activeTimeFilter)}</span>`);}if (activeImpactThreshold > 0) {filterBadges.push(`<span class="filter-badge">Impact ≥ ${activeImpactThreshold}</span>`);@@ -1547,7 +1569,7 @@ function updateFeedHeader() {const sub = subscriptions.find(s => s.id === activeSubscription);if (sub) {const query = sub.query || sub.topic || sub.query_or_topic || 'Unknown';- feedTitle.innerHTML = `News for: <span class="text-muted">${query}</span>`;+ feedTitle.innerHTML = `News for: <span class="text-muted">${escapeHtml(query)}</span>`;}}}@@ -1955,11 +1977,11 @@ async function monitorResearch(researchId, query = null) {<div class="news-header"><h2 class="news-title"><i class="bi bi-hourglass-split spinning"></i>- Analyzing: "${query.substring(0, 60)}..."+ Analyzing: "${escapeHtml(query.substring(0, 60))}..."</h2></div><div class="news-meta">- <span><i class="bi bi-info-circle"></i> Research ID: ${researchId}</span>+ <span><i class="bi bi-info-circle"></i> Research ID: ${escapeHtml(researchId)}</span><span><i class="bi bi-clock"></i> ${statusData.status === 'in_progress' ? 'In progress' : 'Started just now'}</span></div><div class="news-summary">@@ -2313,10 +2335,10 @@ function displayRecentSearches() {item.type === 'table' ? 'bi-table' : 'bi-search';return `- <div class="recent-search-item" onclick="rerunSearch('${item.query.replace(/'/g, "\\'")}', '${item.type}')">+ <div class="recent-search-item" onclick="rerunSearch('${escapeAttr(item.query)}', '${escapeAttr(item.type)}')"<i class="bi ${typeIcon}"></i><div class="flex-grow-1">- <div class="search-query">${item.query}</div>+ <div class="search-query">${escapeHtml(item.query)}</div><div class="search-meta">${timeAgo} • ${item.resultCount || 0} results</div></div><i class="bi bi-arrow-repeat"></i>@@ -3240,11 +3262,11 @@ async function handleNewsSubscriptionSubmit(e) {<div class="news-header"><h2 class="news-title"><i class="bi bi-hourglass-split spinning"></i>- Running subscription: "${query.substring(0, 60)}..."+ Running subscription: "${escapeHtml(query.substring(0, 60))}..."</h2></div><div class="news-meta">- <span><i class="bi bi-info-circle"></i> Research ID: ${runData.research_id}</span>+ <span><i class="bi bi-info-circle"></i> Research ID: ${escapeHtml(runData.research_id)}</span><span><i class="bi bi-clock"></i> Started just now</span></div><div class="news-summary">