From efaa2d07e7c3d5ae07e806f91859ae037194c05e Mon Sep 17 00:00:00 2001 From: huglope <114180217+huglope@users.noreply.github.com> Date: Thu, 19 Sep 2024 12:56:14 +0200 Subject: [PATCH] Fix code scanning alert #9: DOM text reinterpreted as HTML Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- src/main/webapp/scripts/create_new_topic.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/scripts/create_new_topic.js b/src/main/webapp/scripts/create_new_topic.js index a3ad18d..aed0a2d 100644 --- a/src/main/webapp/scripts/create_new_topic.js +++ b/src/main/webapp/scripts/create_new_topic.js @@ -27,12 +27,12 @@ function toggleModal() { action.addEventListener('click', function() { var result = parseInt(this.dataset.confirm); if (result === 1) { - var title = document.getElementById('title').value; - var message = document.getElementById('message').value; + var title = encodeURIComponent(document.getElementById('title').value); + var message = encodeURIComponent(document.getElementById('message').value); let queryString = window.location.search; let urlParams = new URLSearchParams(queryString); var idForo = urlParams.get('idForo'); - window.location.href = '/CreateTopic?idForo=' + idForo + '&title='+title+'&message='+message; + window.location.href = '/CreateTopic?idForo=' + idForo + '&title=' + title + '&message=' + message; } else { wrapper.classList.remove('active'); setTimeout(function() {