jsonmaur / xss-clean Goto Github PK
View Code? Open in Web Editor NEWMiddleware to sanitize user input
Middleware to sanitize user input
@jsonmaur I'm contacting you here because I can't reach you on the now archived repo https://github.com/jsonmaur/xss-clean
I've just installed the latest xss-clean 0.1.3 and when I start my app, it doesn't find the lib folder in node_modules/xss-clean
Checked and I can only see package.json and README.md so there must have happened something wrong with the build process.
It would be good to un-archive it until these kinds of issues are ironed out.
I have reverted to the 7-year old 0.1.1 for the moment.
Thanks and sorry for opening an issue in this unrelated repo!
I am using this package as a middleware in Express and it works fine, but I am also using EditorJs as my rich text editor in front-end. My problem is that EditorJs generates an object which there is html in it, and I don't want to sanitize the incoming object of EditorJs. So I am asking if there is a way to exclude some fields (in my case it is "req.body.editorObj") from sanitizing process?
Hi @jsonmaur
I was having some issues integrating into typescript as the types are missing. I tried creating a xss-clean.d.ts file which did not help.
I ended up creating a custom middle ware and dumped your code to it with some changes like this. Is it ok for me to do this?
import { inHTMLData } from 'xss-filters';
import { RequestHandler, Request } from 'express';
const clean = (req: Request): Request => {
if (req.body)
req.body = JSON.parse(inHTMLData(JSON.stringify(req.body)).trim());
if (req.query)
req.query = JSON.parse(inHTMLData(JSON.stringify(req.query)).trim());
if (req.params)
req.params = JSON.parse(inHTMLData(JSON.stringify(req.params)).trim());
return req;
};
const xss = (): RequestHandler => {
return (req, _res, next) => {
req = clean(req);
next();
};
};
export default xss;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.