From c81a164cae327d0c92e6cda239ce4eccc02f5354 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Mon, 4 Aug 2025 23:41:37 +0100 Subject: [PATCH] Potential fix for code scanning alert no. 303: DOM text reinterpreted as HTML Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .../main/resources/static/js/githubVersion.js | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/app/core/src/main/resources/static/js/githubVersion.js b/app/core/src/main/resources/static/js/githubVersion.js index a6b8c8a7e..2788d7c28 100644 --- a/app/core/src/main/resources/static/js/githubVersion.js +++ b/app/core/src/main/resources/static/js/githubVersion.js @@ -205,6 +205,18 @@ async function showUpdateModal() { const updateBtn = document.getElementById("update-btn"); const summaryData = JSON.parse(updateBtn.getAttribute('data-update-summary')); + // Utility function to escape HTML special characters + function escapeHtml(str) { + if (typeof str !== 'string') return str; + return str + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/\//g, '/'); + } + // Create initial modal with loading state const initialModalHtml = ` @@ -254,9 +266,9 @@ async function showUpdateModal() { ${summaryData.migration_guides.map(guide => `
  • - Version ${guide.version}: ${guide.notes} + Version ${escapeHtml(guide.version)}: ${escapeHtml(guide.notes)}
    - View Guide + View Guide
  • `).join('')} @@ -273,7 +285,7 @@ async function showUpdateModal() {