Skip to content

Commit

Permalink
Replace innerHTML() with createElement() and appendChild() for security.
Browse files Browse the repository at this point in the history
  • Loading branch information
ubertao committed Sep 20, 2018
1 parent 40725aa commit cad7deb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/default/compliments/compliments.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down

0 comments on commit cad7deb

Please sign in to comment.