Skip to content

Commit

Permalink
dm-4881 dom text reinterpret / xss codeql warning 3 (#1133)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeFraties authored Dec 6, 2024
1 parent 0b9d84b commit 6df982d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions app/assets/javascripts/practice_page.es6
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,11 @@
const moreText = 'See more';
const lessText = 'See less';
let t = $(element).text();
let firstHalf = `${t.slice(
0,
showChar
)}<span>${ellipsesText} </span><button type="button" class="dm-button--unstyled-primary more-link">${moreText}</button>`;
let secondHalf = `<span style="display:none;">${t.slice(
showChar,
t.length
)} <button type="button" class="dm-button--unstyled-primary less-link">${lessText}</button></span>`;
let firstHalf = `${_.escape(t.slice(0, showChar))}<span>${ellipsesText} </span>
<button type="button" class="dm-button--unstyled-primary more-link">${moreText}</button>`;
let secondHalf = `<span style="display:none;">${_.escape(t.slice(showChar, t.length))}
<button type="button" class="dm-button--unstyled-primary less-link">${lessText}</button></span>`;

if (t.length < showChar) return;

$(element).html(firstHalf + secondHalf);
Expand Down

0 comments on commit 6df982d

Please sign in to comment.