Skip to content

querystring stringify/parse is inconsistent and does not roundtrip #62814

Description

@ChALkeR
> querystring.stringify({ foo: "a\ud802" })
Uncaught URIError [ERR_INVALID_URI]: URI malformed // correct
> querystring.stringify({ foo: "a\ud802b" })
'foo=a%F0%90%A1%A2' // incorrect
> encodeURIComponent("a\ud802b")
Uncaught URIError: URI malformed // correct
> foo = "a\ud802b"; querystring.parse(querystring.stringify({ foo })).foo === foo
false // does not roundtrip

I would argue that "a\ud802b" was supposed to throw, as querystring.stringify is already throwing on some non-well-formed strings, it just misses some

See also anonrig/fast-querystring#92

This was autodetected by the scanner behind https://github.com/deepview-autofix

For anyone remembering querystring being moved to Legacy: https://nodejs.org/api/querystring.html has been updated from Legacy to Stable, and is currently labeled Stable in the docs, see #44912

Activity

  1. added
    querystringIssues and PRs related to the built-in querystring module.
    on Apr 19, 2026
  2. ChALkeR commented on Apr 19, 2026

    @ChALkeR
    MemberAuthor

    cc @mcollina and @anonrig as people interacting with querystring, wdyt should happen here?

  3. mcollina commented on Apr 19, 2026

    @mcollina
    SponsorMember

    I would recommend fixing. The standard-based alternative is so much slower that this is important to keep in core.

  4. self-assigned this
    on Apr 19, 2026
  5. github-actions commented on Jul 20, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 90 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  6. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jul 20, 2026
  7. github-actions commented on Aug 20, 2026

    @github-actions
    Contributor

    This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
    If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

querystringIssues and PRs related to the built-in querystring module.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions