mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 20:22:53 +00:00
Replace innerHTML() with createElement() and appendChild() for security.
This commit is contained in:
parent
40725aa2a2
commit
cad7debc5b
@ -157,10 +157,15 @@ Module.register("compliments", {
|
||||
getDom: function() {
|
||||
var complimentText = this.randomCompliment();
|
||||
|
||||
var compliment = document.createTextNode(complimentText);
|
||||
var wrapper = document.createElement("div");
|
||||
wrapper.className = this.config.classes ? this.config.classes : "thin xlarge bright";
|
||||
wrapper.innerHTML = complimentText.replace(/\n/g, '<br>');
|
||||
complimentText.split("\n").forEach(function(line, index) {
|
||||
if (index > 0) {
|
||||
wrapper.appendChild(document.createElement("br"));
|
||||
}
|
||||
wrapper.appendChild(document.createTextNode(line));
|
||||
|
||||
});
|
||||
|
||||
return wrapper;
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user