Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

querystring.parse() not handling trailing spaces (+) in parameters correctly #14215

Closed
jaysylvester opened this issue Jul 13, 2017 · 2 comments
Closed
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. querystring Issues and PRs related to the built-in querystring module.

Comments

@jaysylvester
Copy link

jaysylvester commented Jul 13, 2017

I'm seeing an issue with querystring.parse() in v8.4.1 that I don't have with v6.11.1. When I parse application/x-www-form-urlencoded form data, inputs containing returns and line feeds with a trailing space on the last line aren't parsing correctly.

Let's say I have <textarea name="content"> that contains the following on submit:

foo
bar

I get the expected result after parsing the form body:

foo\r\nbar

However, if I add a trailing space after "bar", I get the following form body:

content=foo%0D%0Abar+

And the following from querystring.parse():

{
  content: 'foo%0D%0Abar '
}

I'm using formidable and thought it might be a bug in that, so I wrote a simple parser myself and still have the same issue.

var body = '',
    form = {};

request.on('data', function (chunk) {
  body += chunk.toString();
});

request.on('end', function () {
  form = querystring.parse(body);
});

As mentioned previously, everything works as expected using v6.11.1. Not sure if this is an intentional change that I missed or a bug.

@jaysylvester jaysylvester changed the title querystring.parse() not handling returns/newlines with trailing spaces correctly querystring.parse() not handling trailing spaces (+) in parameters correctly Jul 13, 2017
@TimothyGu TimothyGu added duplicate Issues and PRs that are duplicates of other issues or PRs. querystring Issues and PRs related to the built-in querystring module. labels Jul 13, 2017
@TimothyGu
Copy link
Member

Duplicate of #13773. The bug has already been fixed in master, and the next v8.x release will have it fixed also.

@jaysylvester
Copy link
Author

Sorry, searched but didn't find that issue. Thanks for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. querystring Issues and PRs related to the built-in querystring module.
Projects
None yet
Development

No branches or pull requests

2 participants