|
|
@@ -33,15 +33,57 @@ const validator = {
|
|
|
* name: MarkDownSetting
|
|
|
*/
|
|
|
|
|
|
+/**
|
|
|
+ * @swagger
|
|
|
+ *
|
|
|
+ * components:
|
|
|
+ * schemas:
|
|
|
+ * lineBreakParams:
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * isEnabledLinebreaks:
|
|
|
+ * type: boolean
|
|
|
+ * description: enable lineBreak
|
|
|
+ * isEnabledLinebreaksInComments:
|
|
|
+ * type: boolean
|
|
|
+ * description: enable lineBreak in comment
|
|
|
+ * presentationParams:
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * pageBreakSeparator:
|
|
|
+ * type: number
|
|
|
+ * description: number of pageBreakSeparator
|
|
|
+ * pageBreakCustomSeparator:
|
|
|
+ * type: string
|
|
|
+ * description: string of pageBreakCustomSeparator
|
|
|
+ * xssParams:
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * isEnabledPrevention:
|
|
|
+ * type: boolean
|
|
|
+ * description: enable xss
|
|
|
+ * xssOption:
|
|
|
+ * type: number
|
|
|
+ * description: number of xss option
|
|
|
+ * tagWhiteList:
|
|
|
+ * type: array
|
|
|
+ * description: array of tag whiteList
|
|
|
+ * items:
|
|
|
+ * type: string
|
|
|
+ * description: tag whitelist
|
|
|
+ * attrWhiteList:
|
|
|
+ * type: array
|
|
|
+ * description: array of attr whiteList
|
|
|
+ * items:
|
|
|
+ * type: string
|
|
|
+ * description: attr whitelist
|
|
|
+ */
|
|
|
+
|
|
|
module.exports = (crowi) => {
|
|
|
const loginRequiredStrictly = require('../../middleware/login-required')(crowi);
|
|
|
const adminRequired = require('../../middleware/admin-required')(crowi);
|
|
|
const csrf = require('../../middleware/csrf')(crowi);
|
|
|
|
|
|
- // const {
|
|
|
- // Config,
|
|
|
- // } = crowi.models;
|
|
|
-
|
|
|
const { ApiV3FormValidator } = crowi.middlewares;
|
|
|
|
|
|
/**
|
|
|
@@ -67,17 +109,27 @@ module.exports = (crowi) => {
|
|
|
* responses:
|
|
|
* 200:
|
|
|
* description: Succeeded to update lineBreak setting
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * properties:
|
|
|
+ * status:
|
|
|
+ * $ref: '#/components/schemas/lineBreakParams'
|
|
|
*/
|
|
|
router.put('/lineBreak', loginRequiredStrictly, adminRequired, csrf, validator.lineBreak, ApiV3FormValidator, async(req, res) => {
|
|
|
|
|
|
- const lineBreakParams = {
|
|
|
+ const requestLineBreakParams = {
|
|
|
'markdown:isEnabledLinebreaks': req.body.isEnabledLinebreaks,
|
|
|
'markdown:isEnabledLinebreaksInComments': req.body.isEnabledLinebreaksInComments,
|
|
|
};
|
|
|
|
|
|
try {
|
|
|
- await crowi.configManager.updateConfigsInTheSameNamespace('markdown', lineBreakParams);
|
|
|
- return res.apiv3({ lineBreakParams });
|
|
|
+ await crowi.configManager.updateConfigsInTheSameNamespace('markdown', requestLineBreakParams);
|
|
|
+ const lineBreaksParams = {
|
|
|
+ isEnabledLinebreaks: await crowi.configManager.getConfig('markdown', 'markdown:isEnabledLinebreaks'),
|
|
|
+ isEnabledLinebreaksInComments: await crowi.configManager.getConfig('markdown', 'markdown:isEnabledLinebreaksInComments') || '',
|
|
|
+ };
|
|
|
+ return res.apiv3({ lineBreaksParams });
|
|
|
}
|
|
|
catch (err) {
|
|
|
const msg = 'Error occurred in updating lineBreak';
|
|
|
@@ -110,6 +162,12 @@ module.exports = (crowi) => {
|
|
|
* responses:
|
|
|
* 200:
|
|
|
* description: Succeeded to update presentation setting
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * properties:
|
|
|
+ * status:
|
|
|
+ * $ref: '#/components/schemas/presentationParams'
|
|
|
*/
|
|
|
router.put('/presentation', loginRequiredStrictly, adminRequired, csrf, validator.presentationSetting, ApiV3FormValidator, async(req, res) => {
|
|
|
if (req.body.pageBreakSeparator === 3 && req.body.pageBreakCustomSeparator === '') {
|
|
|
@@ -172,13 +230,19 @@ module.exports = (crowi) => {
|
|
|
* responses:
|
|
|
* 200:
|
|
|
* description: Succeeded to update xss setting
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * properties:
|
|
|
+ * status:
|
|
|
+ * $ref: '#/components/schemas/xssParams'
|
|
|
*/
|
|
|
router.put('/xss', loginRequiredStrictly, adminRequired, csrf, validator.xssSetting, ApiV3FormValidator, async(req, res) => {
|
|
|
if (req.body.isEnabledXss && req.body.xssOption == null) {
|
|
|
return res.apiv3Err(new ErrorV3('xss option is required'));
|
|
|
}
|
|
|
|
|
|
- const xssParams = {
|
|
|
+ const reqestXssParams = {
|
|
|
'markdown:xss:isEnabledPrevention': req.body.isEnabledXss,
|
|
|
'markdown:xss:option': req.body.xssOption,
|
|
|
'markdown:xss:tagWhiteList': req.body.tagWhiteList,
|
|
|
@@ -186,7 +250,13 @@ module.exports = (crowi) => {
|
|
|
};
|
|
|
|
|
|
try {
|
|
|
- await crowi.configManager.updateConfigsInTheSameNamespace('markdown', xssParams);
|
|
|
+ await crowi.configManager.updateConfigsInTheSameNamespace('markdown', reqestXssParams);
|
|
|
+ const xssParams = {
|
|
|
+ isEnabledXss: await crowi.configManager.getConfig('markdown', 'markdown:xss:isEnabledPrevention'),
|
|
|
+ xssOption: await crowi.configManager.getConfig('markdown', 'markdown:xss:option'),
|
|
|
+ tagWhiteList: await crowi.configManager.getConfig('markdown', 'markdown:xss:tagWhiteList'),
|
|
|
+ attrWhiteList: await crowi.configManager.getConfig('markdown', 'markdown:xss:attrWhiteList'),
|
|
|
+ };
|
|
|
return res.apiv3({ xssParams });
|
|
|
}
|
|
|
catch (err) {
|