Giter Site home page Giter Site logo

Comments (11)

dougwilson avatar dougwilson commented on April 24, 2024

Yea. You need to either use {extended: false} or ask over at https://github.com/hapijs/qs/ to make the parametersLimit configurable and I can expose the configuration here.

It also seems like you're sending a really big object over urlencoded. Perhaps you just want to use JSON :)?

from body-parser.

dougwilson avatar dougwilson commented on April 24, 2024

and in case you were wondering, the reason this changed in a non-major version is because using bodyParser.urlencoded({ extended: true }) with version < 1.6.0 expose the server to a really easy DoS attack.

from body-parser.

jackryon avatar jackryon commented on April 24, 2024

Thanks for the quick reply.
Using extended: false with 1.6.0 still yields incomplete data, though.

bp-1 6 0-extended-false

I'm about to try sending up application/json.

from body-parser.

dougwilson avatar dougwilson commented on April 24, 2024

Using extended: false with 1.6.0 still yields incomplete data, though.

Ah, yes, I forgot Node.js core also has a default limit of 1,000 parameters (though it's limit is configurable): https://github.com/joyent/node/blob/v0.10.24/lib/querystring.js#L172

I'm going to talk with the qs guys to get theirs parameter limit configurable and I can expose the configuration, but yea, overall I think your use-case may be better served using JSON instead of urlencoded if you are not using a straight up HTML <form> to make the submission.

from body-parser.

jackryon avatar jackryon commented on April 24, 2024

Awesome. I appreciate your help.

from body-parser.

dougwilson avatar dougwilson commented on April 24, 2024

So for the extended module, there is no way right now it can even handle > 1000 parameters. Feeding it 2000 parameters make it take ~1710ms on my machine, an eternity.

from body-parser.

dougwilson avatar dougwilson commented on April 24, 2024

If you wish to keep using very large urlencoded payloads, you will be able to configure the limit in the upcoming 1.7.0:

app.use(bodyParser.urlencoded({ extended: true, parameterLimit: 5000 }))

from body-parser.

dougwilson avatar dougwilson commented on April 24, 2024

In addition, the module will no longer give you weird truncated req.body and will instead completely reject the payload with a 415 if there are too many parameters so you are not accidentally processing an incomplete payload.

from body-parser.

jkrems avatar jkrems commented on April 24, 2024

Are the 1710ms a pathological example or is this really the expected runtime for parsing 2000 elements? It seems like a lot.

from body-parser.

dougwilson avatar dougwilson commented on April 24, 2024

Are the 1710ms a pathological example or is this really the expected runtime for parsing 2000 elements? It seems like a lot.

It is a real example. qs has fixed this, though, so it only takes 80ms now for the same parse.

from body-parser.

jkrems avatar jkrems commented on April 24, 2024

Ah, thanks. Glad to hear that, got me nervous for a minute! :)

from body-parser.

Related Issues (20)

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.