|
@@ -147,6 +147,17 @@ module.exports = function(crowi, app) {
|
|
|
const interceptorManager = crowi.getInterceptorManager();
|
|
const interceptorManager = crowi.getInterceptorManager();
|
|
|
const globalNotificationService = crowi.getGlobalNotificationService();
|
|
const globalNotificationService = crowi.getGlobalNotificationService();
|
|
|
|
|
|
|
|
|
|
+ const XssOption = require('../../lib/service/xss/xssOption');
|
|
|
|
|
+ const Xss = require('../../lib/service/xss/index');
|
|
|
|
|
+ const initializedConfig = {
|
|
|
|
|
+ isEnabledXssPrevention: crowi.configManager.getConfig('markdown', 'markdown:xss:isEnabledPrevention'),
|
|
|
|
|
+ tagWhiteList: crowi.xssService.getTagWhiteList(),
|
|
|
|
|
+ attrWhiteList: crowi.xssService.getAttrWhiteList(),
|
|
|
|
|
+ };
|
|
|
|
|
+ const xssOption = new XssOption(initializedConfig);
|
|
|
|
|
+ const xss = new Xss(xssOption);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
const actions = {};
|
|
const actions = {};
|
|
|
|
|
|
|
|
function getPathFromRequest(req) {
|
|
function getPathFromRequest(req) {
|
|
@@ -230,6 +241,11 @@ module.exports = function(crowi, app) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function addRenderVarsForPresentation(renderVars, page) {
|
|
function addRenderVarsForPresentation(renderVars, page) {
|
|
|
|
|
+ // sanitize page.revision.body
|
|
|
|
|
+ if (crowi.configManager.getConfig('markdown', 'markdown:xss:isEnabledPrevention')) {
|
|
|
|
|
+ const preventXssRevision = xss.process(page.revision.body);
|
|
|
|
|
+ page.revision.body = preventXssRevision;
|
|
|
|
|
+ }
|
|
|
renderVars.page = page;
|
|
renderVars.page = page;
|
|
|
renderVars.revision = page.revision;
|
|
renderVars.revision = page.revision;
|
|
|
}
|
|
}
|