Browse Source

fix: insecure-document-method-226

pull/14752/head
root 6 months ago
parent
commit
b35a922e40
  1. 22
      docs/en/docs/js/termynal.js

22
docs/en/docs/js/termynal.js

@ -222,10 +222,26 @@ class Termynal {
*/ */
lineDataToElements(lineData) { lineDataToElements(lineData) {
return lineData.map(line => { return lineData.map(line => {
let div = document.createElement('div'); let span = document.createElement('span');
div.innerHTML = `<span ${this._attributes(line)}>${line.value || ''}</span>`;
return div.firstElementChild; // Safely set text content instead of using innerHTML
span.textContent = line.value || '';
// Safely set attributes
for (let prop in line) {
// Custom add class
if (prop === 'class') {
span.className = line[prop];
continue;
}
if (prop === 'type') {
span.setAttribute(this.pfx, line[prop]);
} else if (prop !== 'value') {
span.setAttribute(`${this.pfx}-${prop}`, line[prop]);
}
}
return span;
}); });
} }

Loading…
Cancel
Save