Skip to content

Commit bb46aa2

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

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

assets/src/js/functions/text-shortener.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@ function initTextShortener() {
3333
const visibleText = text.substr(0, showChars);
3434
const hiddenText = text.substr(showChars, text.length - showChars);
3535

36-
$(element).html(
37-
'<span class="shortcontent">' + visibleText + '...</span>' +
38-
'<span class="allcontent">' + text + '</span>'
39-
);
36+
// Ricostruisci il contenuto usando nodi di testo per evitare XSS
37+
$(element).empty();
38+
39+
const $shortSpan = $('<span class="shortcontent"></span>');
40+
$shortSpan.text(visibleText + '...');
41+
42+
const $allSpan = $('<span class="allcontent"></span>');
43+
$allSpan.text(text);
44+
45+
$(element).append($shortSpan).append($allSpan);
4046

4147
$(element).find('.allcontent').hide();
4248
}

0 commit comments

Comments
 (0)