Skip to content

Commit dfb81af

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 cffef7a commit dfb81af

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

script.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,17 @@ invoiceNameInput.addEventListener('input', () => {
7272
analyzeButton.disabled = selectedFiles.length === 0 || !invoiceNameInput.value.trim();
7373
});
7474

75+
function escapeHtml(unsafe) {
76+
return unsafe
77+
.replace(/&/g, "&amp;")
78+
.replace(/</g, "&lt;")
79+
.replace(/>/g, "&gt;")
80+
.replace(/"/g, "&quot;")
81+
.replace(/'/g, "&#039;");
82+
}
83+
7584
function updateFileList() {
76-
fileList.innerHTML = selectedFiles.map(file => `<p>${file.name}</p>`).join('');
85+
fileList.innerHTML = selectedFiles.map(file => `<p>${escapeHtml(file.name)}</p>`).join('');
7786
}
7887

7988
analyzeButton.addEventListener('click', analyzeInvoices);

0 commit comments

Comments
 (0)