GithubHelp home page GithubHelp logo

express-sanitizer's People

Contributors

askhogan avatar jemiloii avatar markau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

express-sanitizer's Issues

Unexpected end of JSON input

I am getting SyntaxError: Unexpected end of JSON input

Its only if i enter a value like this <HUI. If I put a space between the angle bracket and the word its fine, its only when its one word, no spaces.

My Code:

app.use((req, res, next) => {
  if( req.body ){

    console.log(typeof req.body); //object
    console.log(JSON.stringify(req.body)); // {"obj":"<HUI"}

    let sanitizedBody = req.sanitize(JSON.stringify(req.body));
    console.log(sanitizedBody) // {"obj":"

    // check if bodies differ to send an alert to slack
    if( sanitizedBody != JSON.stringify(req.body) ){
      console.log('Has been sanitised');
    }

    req.body = JSON.parse(sanitizedBody); 
    ^--- error is from this line, because trying to parse a broken object

  }
  next();
});

options

What are the options for sanitizer?

Question: How to best handle redirect URIs in query params?

I'm running into an issue where sanitizer is breaking redirect URLs; what's the best way to handle a URL in a query param (e.g. www.mysite.com/?redirect=/my/ampersands/get/replaced) that's getting encoded from www.redirectExample.com/?ampersands=get&converted=to to www.redirectExample.com/?ampersands=get&amp;converted=to?

Our best thought for a generic solution is to regex for url query params and do a simple find-replace on &amp; but I dunno if there's a cleaner way to go.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.