Skip to content

Commit 2677ae5

Browse files
Potential fix for code scanning alert no. 1: DOM text reinterpreted as HTML
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 69c29c3 commit 2677ae5

File tree

1 file changed

+10
-1
lines changed
  • SIS/clarin/resources/scripts

1 file changed

+10
-1
lines changed

SIS/clarin/resources/scripts/edit.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ if (typeof String.prototype.startsWith != 'function') {
77
};
88
}
99

10+
function escapeHtml(unsafe) {
11+
return unsafe
12+
.replace(/&/g, "&amp;")
13+
.replace(/</g, "&lt;")
14+
.replace(/>/g, "&gt;")
15+
.replace(/"/g, "&quot;")
16+
.replace(/'/g, "&#039;");
17+
}
18+
1019
function showResp(resptype,resporg,respname){
1120
e = document.getElementById(resptype);
1221
if (e.options[e.selectedIndex].value == 'person'){
@@ -443,7 +452,7 @@ function addDesc(specid,parentid,pids){
443452

444453
s = document.createElement("span")
445454
s.id="desc"+newpid+"text"
446-
s.appendChild(document.createTextNode(text)) // New description text
455+
s.appendChild(document.createTextNode(escapeHtml(text))) // New description text
447456
// Dummy strings to allocate different element variables
448457
b1 = createButton("b1","edit","Edit","edit",newpid,specid,pids) // New edit button
449458
b2 = createButton("b2","edit","Add","add",newpid,specid,pids) // New add button

0 commit comments

Comments
 (0)