Skip to content

querystring inconsistent behaviour #33910

Description

@scucchiero

The module querystring presents odd behaviour and inconsistent across platforms.

On NodeJs v14.2 x86_64 GNU/Linux
Parsing an object with an empty array into a querystring yields & with no element.

const querystring = require('querystring')
> querystring.stringify({ a:2, b:[] })
'a=2&' // expected result --> a=2 or a=2&b= 

On Firefox 77.0.1 (64-bit)
Yet, when using the module in a react application with client side rendering the result is as follows:

import querystring from 'querystring'
> querystring.stringify({ a:2, b:[] }) // 'a=2'  

This issue can lead to some of the following malformed URLs which may fault some server parsers. (My experience was with WSGI server)

Activity

  1. jasnell commented on Jun 16, 2020

    @jasnell
    Member

    Note that the version running within Firefox is likely a browserified version that is derived from the Node.js version. That's a bit of a guess without seeing the code but it is possible for there to be differences in the way they are implemented. We do not provide support for browserified ports of the core modules.

  2. sapics commented on Jun 17, 2020

    @sapics
    Contributor

    I guess that a=2 would be more expected one, because querystring.stringify({ a: [], b: [] }) is empty string.
    I try to fix and make a PR.

  3. sapics commented on Jun 17, 2020

    @sapics
    Contributor

    I create a PR #33918. There were some errors at early commit, now it is fixed.
    If there are something I was missing or you have any additional information, I'd appreciate it if you make a comment here or PR ;)

  4. scucchiero commented on Jun 17, 2020

    @scucchiero
    Author

    great job mate, that was pretty quick.
    so far that is the only things that I caught.
    I will make sure to post anything else me or my team notice.

  5. targos commented on Dec 27, 2020

    @targos
    Member

    Fixed by #33918

  6. added
    querystringIssues and PRs related to the built-in querystring module.
    on Dec 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    querystringIssues and PRs related to the built-in querystring module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions