Skip to content

Commit edc3a31

Browse files
committed
Fix XSS HTML replace might get wrong on the HTML comments in the code tags
1 parent 0fb70a1 commit edc3a31

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

public/js/render.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ var whiteListAttr = ['id', 'class', 'style'];
33

44
var filterXSSOptions = {
55
allowCommentTag: true,
6+
escapeHtml: function (html) {
7+
// to allow html comment in multiple lines
8+
return html.replace(/<(.*?)>/g, '&lt;$1&gt;');
9+
},
610
onIgnoreTag: function (tag, html, options) {
711
// allow style in html
812
if (whiteListTag.indexOf(tag) !== -1) {

0 commit comments

Comments
 (0)