X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=server%2Froutes%2Fproblems.js;h=5f4dd401d184acdb16fca9f66252bbbce84689db;hb=2bb4666e276e837add0958554a11b38f7f4d9357;hp=2db81bbc6161afceb2582311c2591345351be694;hpb=84fc0f02d3d399af66c40b3e9994f67b415ffd0e;p=vchess.git diff --git a/server/routes/problems.js b/server/routes/problems.js index 2db81bbc..5f4dd401 100644 --- a/server/routes/problems.js +++ b/server/routes/problems.js @@ -1,7 +1,17 @@ let router = require("express").Router(); const access = require("../utils/access"); +const params = require("../config/parameters"); const ProblemModel = require("../models/Problem"); -const sanitizeHtml = require('sanitize-html'); +const sanitizeHtml_pkg = require('sanitize-html'); + +const allowedTags = [ + 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol', 'li', 'b', + 'i', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div', 'table', + 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre' +]; +function sanitizeHtml(text) { + return sanitizeHtml_pkg(text, { allowedTags: allowedTags }); +} router.post("/problems", access.logged, access.ajax, (req,res) => { if (ProblemModel.checkProblem(req.body.prob)) { @@ -41,7 +51,7 @@ router.put("/problems", access.logged, access.ajax, (req,res) => { if (ProblemModel.checkProblem(obj)) { obj.instruction = sanitizeHtml(obj.instruction); obj.solution = sanitizeHtml(obj.solution); - ProblemModel.safeUpdate(obj, req.userId); + ProblemModel.safeUpdate(obj, req.userId, params.devs); } res.json({}); }); @@ -49,7 +59,7 @@ router.put("/problems", access.logged, access.ajax, (req,res) => { router.delete("/problems", access.logged, access.ajax, (req,res) => { const pid = req.query.id; if (pid.toString().match(/^[0-9]+$/)) - ProblemModel.safeRemove(pid, req.userId); + ProblemModel.safeRemove(pid, req.userId, params.devs); res.json({}); });