Click here to Skip to main content
15,041,025 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi !~

I have a file middleware.js which contains a method

JavaScript
module.exports.handleRecalc = (req, res, next) => {
  if (req.method === 'POST' && req.url.includes('application/recalculate')) {
    const recalcStructure = structureService.recalc(req.body);
    res.send(recalcStructure);
  } else {
    next();
  }
};


Now, when I create a pull request on Github, Checkmark will complain about sending req.body un-sanitized or not encoded.


Does anyone have any suggestion on how I can get rid of that error?

Thank you!

What I have tried:

I tried to add the following lines in the method:

 <pre lang="Javascript">
const sanitizedReqBody = expAutoSan.sanitizeIt(req.body);
const recalcStructure = structureService.recalc(sanitizedReqBody);

and I imported

JavaScript
const expAutoSan = require('express-autosanitizer');


, but the error is still there on checkmark.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900