mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 23:24:46 -04:00
Fixed prevent XSS might break lots of tags and only need after rendered
This commit is contained in:
parent
176021ccd8
commit
4c4a0e0f3f
10 changed files with 442 additions and 20 deletions
13
public/js/render.js
Normal file
13
public/js/render.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
function preventXSS(html) {
|
||||
var options = {
|
||||
allowCommentTag: true,
|
||||
onIgnoreTagAttr: function (tag, name, value, isWhiteAttr) {
|
||||
// allow attr start with 'data-' or equal 'id' and 'class'
|
||||
if (name.substr(0, 5) === 'data-' || name === 'id' || name === 'class') {
|
||||
// escape its value using built-in escapeAttrValue function
|
||||
return name + '="' + filterXSS.escapeAttrValue(value) + '"';
|
||||
}
|
||||
}
|
||||
};
|
||||
return filterXSS(html, options);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue