Browse Source
Merge pull request #3 from Tanmaykaturi/fix/semgrep-insecure-document-method-226-lmuuTeaFK7
fix: semgrep-insecure-document-method
pull/14752/head
Tanmaykaturi
6 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
19 additions and
3 deletions
-
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>`; |
|
|
|
|
|
|
|
|
// 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 div.firstElementChild; |
|
|
return span; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|