mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-29 12:39:45 +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() {
|
getDom: function() {
|
||||||
var complimentText = this.randomCompliment();
|
var complimentText = this.randomCompliment();
|
||||||
|
|
||||||
var compliment = document.createTextNode(complimentText);
|
|
||||||
var wrapper = document.createElement("div");
|
var wrapper = document.createElement("div");
|
||||||
wrapper.className = this.config.classes ? this.config.classes : "thin xlarge bright";
|
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;
|
return wrapper;
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user