mirror of https://github.com/status-im/codimd.git
Fix render.js code styles
This commit is contained in:
parent
cac618eca8
commit
0f3b028ed6
|
@ -26,30 +26,30 @@ var filterXSSOptions = {
|
||||||
allowCommentTag: true,
|
allowCommentTag: true,
|
||||||
whiteList: whiteList,
|
whiteList: whiteList,
|
||||||
escapeHtml: function (html) {
|
escapeHtml: function (html) {
|
||||||
// allow html comment in multiple lines
|
// allow html comment in multiple lines
|
||||||
return html.replace(/<(.*?)>/g, '<$1>')
|
return html.replace(/<(.*?)>/g, '<$1>')
|
||||||
},
|
},
|
||||||
onIgnoreTag: function (tag, html, options) {
|
onIgnoreTag: function (tag, html, options) {
|
||||||
// allow comment tag
|
// allow comment tag
|
||||||
if (tag === '!--') {
|
if (tag === '!--') {
|
||||||
// do not filter its attributes
|
// do not filter its attributes
|
||||||
return html
|
return html
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onTagAttr: function (tag, name, value, isWhiteAttr) {
|
onTagAttr: function (tag, name, value, isWhiteAttr) {
|
||||||
// allow href and src that match linkRegex
|
// allow href and src that match linkRegex
|
||||||
if (isWhiteAttr && (name === 'href' || name === 'src') && linkRegex.test(value)) {
|
if (isWhiteAttr && (name === 'href' || name === 'src') && linkRegex.test(value)) {
|
||||||
return name + '="' + filterXSS.escapeAttrValue(value) + '"'
|
return name + '="' + filterXSS.escapeAttrValue(value) + '"'
|
||||||
}
|
}
|
||||||
// allow data uri in img src
|
// allow data uri in img src
|
||||||
if (isWhiteAttr && (tag === 'img' && name === 'src') && dataUriRegex.test(value)) {
|
if (isWhiteAttr && (tag === 'img' && name === 'src') && dataUriRegex.test(value)) {
|
||||||
return name + '="' + filterXSS.escapeAttrValue(value) + '"'
|
return name + '="' + filterXSS.escapeAttrValue(value) + '"'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onIgnoreTagAttr: function (tag, name, value, isWhiteAttr) {
|
onIgnoreTagAttr: function (tag, name, value, isWhiteAttr) {
|
||||||
// allow attr start with 'data-' or in the whiteListAttr
|
// allow attr start with 'data-' or in the whiteListAttr
|
||||||
if (name.substr(0, 5) === 'data-' || window.whiteListAttr.indexOf(name) !== -1) {
|
if (name.substr(0, 5) === 'data-' || window.whiteListAttr.indexOf(name) !== -1) {
|
||||||
// escape its value using built-in escapeAttrValue function
|
// escape its value using built-in escapeAttrValue function
|
||||||
return name + '="' + filterXSS.escapeAttrValue(value) + '"'
|
return name + '="' + filterXSS.escapeAttrValue(value) + '"'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue