Skip to content

Commit

Permalink
Fix code scanning alert no. 43: Client-side cross-site scripting
Browse files Browse the repository at this point in the history
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
km719 and github-advanced-security[bot] authored Dec 16, 2024
1 parent 404ed5f commit 2918ae2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion assets/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ document.addEventListener("DOMContentLoaded", function () {
}
pagerLinks +=
'<span class="margin-2">Page ' +
page +
encodeHTML(page) +
" of " +
Math.ceil(totalResults / resultsPerPage) +
"</span>";
Expand All @@ -124,4 +124,12 @@ document.addEventListener("DOMContentLoaded", function () {
}
return currentURL.toString();
}

function encodeHTML(str) {
return str.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#39;");
}
});

0 comments on commit 2918ae2

Please sign in to comment.