Skip to content

Commit f6a9951

Browse files
committed
Update filter XSS to allow attr href starts with '.' or '/'
1 parent b823ed1 commit f6a9951

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

public/js/render.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ var filterXSSOptions = {
1414
return html;
1515
}
1616
},
17+
onTagAttr: function (tag, name, value, isWhiteAttr) {
18+
// allow href starts with '.' or '/'
19+
if (isWhiteAttr && name === 'href' && (value.indexOf('.') == 0 || value.indexOf('/') == 0)) {
20+
return name + '="' + filterXSS.escapeAttrValue(value) + '"';
21+
}
22+
},
1723
onIgnoreTagAttr: function (tag, name, value, isWhiteAttr) {
1824
// allow attr start with 'data-' or in the whiteListAttr
1925
if (name.substr(0, 5) === 'data-' || whiteListAttr.indexOf(name) !== -1) {

0 commit comments

Comments
 (0)