Skip to content

Commit 0064954

Browse files
alexcjohnsonetpinard
authored andcommitted
safer alternatives to .html in a couple of places
1 parent 862f981 commit 0064954

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/lib/notifier.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ module.exports = function(text, displayLength) {
6363
note.transition().call(killNote);
6464
});
6565

66-
note.append('p').html(thisText);
66+
var p = note.append('p');
67+
var lines = thisText.split(/<br\s*\/?>/g);
68+
for(var i = 0; i < lines.length; i++) {
69+
if(i) p.append('br');
70+
p.append('span').text(lines[i]);
71+
}
6772

6873
note.transition()
6974
.duration(700)

src/lib/svg_text_utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ exports.html_entity_decode = function(s) {
4848
var replaced = s.replace(/(&[^;]*;)/gi, function(d) {
4949
if(d === '&lt;') { return '&#60;'; } // special handling for brackets
5050
if(d === '&rt;') { return '&#62;'; }
51+
if(d.indexOf('<') !== -1 || d.indexOf('>') !== -1) { return ''; }
5152
return hiddenDiv.html(d).text(); // everything else, let the browser decode it to unicode
5253
});
5354
hiddenDiv.remove();

0 commit comments

Comments
 (0)