Merge pull request #1046 from SISheogorath/feature/optimizeXSS
Remove the xss library from webpack
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
/* eslint-env browser, jquery */
|
||||
/* global filterXSS */
|
||||
// allow some attributes
|
||||
|
||||
var filterXSS = require('xss')
|
||||
|
||||
var whiteListAttr = ['id', 'class', 'style']
|
||||
window.whiteListAttr = whiteListAttr
|
||||
// allow link starts with '.', '/' and custom protocol with '://', exclude link starts with javascript://
|
||||
@@ -71,5 +73,6 @@ function preventXSS (html) {
|
||||
window.preventXSS = preventXSS
|
||||
|
||||
module.exports = {
|
||||
preventXSS: preventXSS
|
||||
preventXSS: preventXSS,
|
||||
escapeAttrValue: filterXSS.escapeAttrValue
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-env browser, jquery */
|
||||
|
||||
import { preventXSS } from './render'
|
||||
import { preventXSS, escapeAttrValue } from './render'
|
||||
import { md } from './extra'
|
||||
|
||||
/**
|
||||
@@ -259,7 +259,7 @@ import { md } from './extra'
|
||||
while ((matchesClass = mardownClassRegex.exec(classes))) {
|
||||
var name = matchesClass[1]
|
||||
var value = matchesClass[2]
|
||||
if (name.substr(0, 5) === 'data-' || window.whiteListAttr.indexOf(name) !== -1) { elementTarget.setAttribute(name, window.filterXSS.escapeAttrValue(value)) }
|
||||
if (name.substr(0, 5) === 'data-' || window.whiteListAttr.indexOf(name) !== -1) { elementTarget.setAttribute(name, escapeAttrValue(value)) }
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user