Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ljharb/qs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.15.1
Choose a base ref
...
head repository: ljharb/qs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.15.3
Choose a head ref
  • 19 commits
  • 11 files changed
  • 7 contributors

Commits on Nov 4, 2025

  1. Configuration menu
    Copy the full SHA
    a419ce5 View commit details
    Browse the repository at this point in the history

Commits on Mar 13, 2026

  1. [readme] fix grammar

    JoBeGaming authored and ljharb committed Mar 13, 2026
    Configuration menu
    Copy the full SHA
    96755ab View commit details
    Browse the repository at this point in the history

Commits on Apr 24, 2026

  1. [Fix] stringify: apply formatter to encoded key under `strictNull…

    …Handling`
    
    Previously the null branch returned the raw `encoder(prefix, ...)` output
    (or raw `prefix`) without running it through `formatter`.
    With `format: 'RFC1738'` this caused keys containing spaces to serialize as
    `%20` in strict-null mode while the normal primitive path produced `+`,
    yielding inconsistent output for the same key.
    
    Co-Authored-By: Claude <[email protected]>
    Co-Authored-By: DeepView Autofix <[email protected]>
    Co-Authored-By: Nikita Skovoroda <[email protected]>
    Co-Authored-By: Jordan Harband <[email protected]>
    Signed-off-by: Nikita Skovoroda <[email protected]>
    4 people committed Apr 24, 2026
    Configuration menu
    Copy the full SHA
    e3062f7 View commit details
    Browse the repository at this point in the history
  2. [Fix] stringify: use configured delimiter after charsetSentinel

    The `utf8=...` charset sentinel was followed by a hardcoded `&`, ignoring `options.delimiter`.
    With any non-`&` delimiter the output mixed delimiters (e.g. `utf8=%E2%9C%93&a=1;b=2`), breaking self round-tripping.
    Emit the configured delimiter instead, and add a regression test.
    
    Co-Authored-By: Claude <[email protected]>
    Co-Authored-By: DeepView Autofix <[email protected]>
    Co-Authored-By: Nikita Skovoroda <[email protected]>
    Signed-off-by: Nikita Skovoroda <[email protected]>
    3 people authored and ljharb committed Apr 24, 2026
    Configuration menu
    Copy the full SHA
    a0a81ea View commit details
    Browse the repository at this point in the history

Commits on Apr 27, 2026

  1. [Tests] add regression tests for keys containing percent-encoded brac…

    …ket text
    
    Locks in the round-trip and direct-parse behavior for keys containing literal %5B, %5D, %255B, and %255D text.
    ljharb committed Apr 27, 2026
    Configuration menu
    Copy the full SHA
    3a8b94a View commit details
    Browse the repository at this point in the history
  2. [Fix] stringify: skip null/undefined filter-array entries instead o…

    …f crashing in `encoder`
    
    When `filter` is an array, its elements become `objKeys` directly and the top-level loop passes each entry as the recursive `prefix` argument without coercion.
    A `null` or `undefined` entry reached `utils.encode` as the `str` argument and `str.length` threw `TypeError`.
    
    The crash requires two conditions to align: the filter array must contain `null`/`undefined`, and the object being stringified must have a literal `'null'`/`'undefined'` property
    (otherwise `obj[key]` is `undefined` and the typeof-undefined early-return at stringify.js:137 fires before the encoder is called)
    
    Both are reachable from an attacker controlled input in applications that stringify user-submitted JSON with user-selected fields.
    
    Fix this up by skipping `null`/`undefined` filter entries at the top-level loop.
    This somewhat matches `JSON.stringify` replacer-array semantics, which silently ignore non-string/non-number entries.
    `Object.keys` never yields `null`/`undefined`, so the guard only affects user-supplied filter arrays.
    The inner recursive loop already coerces `key` via `String()` when building `keyPrefix`, so it never passes a raw `null` to the encoder.
    ljharb committed Apr 27, 2026
    Configuration menu
    Copy the full SHA
    0c180a4 View commit details
    Browse the repository at this point in the history

Commits on May 16, 2026

  1. [Fix] stringify: skip null/undefined entries in `arrayFormat: 'comm…

    …a'` + `encodeValuesOnly` instead of crashing in `encoder`
    
    When `arrayFormat: 'comma'` and `encodeValuesOnly: true` were both set, the comma branch passed array entries directly to the encoder via `utils.maybeMap` before the per-element null handling in the main loop.
    A `null` or `undefined` entry reached `utils.encode` as the `str` argument and `str.length` threw `TypeError`.
    
    Neither `skipNulls` nor `strictNullHandling` prevented the crash — both are checked downstream of the encode call on line 145, inside the per-`objKeys` loop, but the comma path collapses the entire array into a single `objKeys` entry before the loop runs.
    
    The fix wraps the encoder in a closure that passes `null`/`undefined` through unchanged, so they reach the `join(',')` step as-is.
    This matches the non-`encodeValuesOnly` comma path, which already joins before encoding and produces `a=%2Cb` for `{ a: [null, 'b'] }`; under `encodeValuesOnly` the comma stays unencoded as a separator, yielding `a=,b`.
    Single-null arrays still collapse to `null` via the existing `obj.join(',') || null` and remain subject to `skipNulls` / `strictNullHandling` in the main loop.
    
    Same class of issue as the filter-array path fixed in 0c180a4, introduced in 04eac8d (2021-04-19) when the comma + `encodeValuesOnly` branch was first added.
    ljharb committed May 16, 2026
    Configuration menu
    Copy the full SHA
    21f80b3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5e33d33 View commit details
    Browse the repository at this point in the history
  3. v6.15.2

    ljharb committed May 16, 2026
    Configuration menu
    Copy the full SHA
    9aca407 View commit details
    Browse the repository at this point in the history

Commits on May 21, 2026

  1. [Robustness] utils.merge / utils.assign: avoid invoking `__proto_…

    …_` setter when copying own properties
    
    When object-valued input to `parse` contains a nested object whose own keys include `__proto__`
    (e.g. from `JSON.parse('{"__proto__":...}')`,
    which creates an own data property via CreateDataProperty),
    the `acc[key] = value` assignment in `merge`/`assign` invoked the `Object.prototype.__proto__` accessor and mutated the per-call returned sub-object's [[Prototype]].
    This is not `Object.prototype` pollution - it affects only the returned sub-object, and downstream consumers can guard with `hasOwnProperty` or `plainObjects: true` - but the setter firing as a side effect of property copying is a footgun that the
    string-input path has long guarded against (see `parseObject`'s `decodedRoot !== '__proto__'` check).
    
    Use `Object.defineProperty` for `__proto__` keys so an own data property is created instead.
    ljharb committed May 21, 2026
    Configuration menu
    Copy the full SHA
    9532969 View commit details
    Browse the repository at this point in the history

Commits on Jun 7, 2026

  1. [Fix] utils: respect encoding of surrogate pairs across chunks

    Co-authored-by: QingXuan <[email protected]>
    Co-authored-by: Jordan Harband <[email protected]>
    Q1Xuan and ljharb committed Jun 7, 2026
    Configuration menu
    Copy the full SHA
    59da434 View commit details
    Browse the repository at this point in the history

Commits on Jun 23, 2026

  1. [Fix] parse: enforce throwOnLimitExceeded for cumulative array gr…

    …owth via `combine`/`merge`
    
    `throwOnLimitExceeded` was only honored on the per-part paths in `parse`.
    When an array grew past `arrayLimit` through duplicate-key combination
    (`utils.combine`) or through `utils.merge`'s overflow branches,
    the value was silently converted to an overflow object instead of throwing.
    
    Thread `throwOnLimitExceeded` into `utils.combine` and guard the overflow branches in `utils.merge`,
    so the option throws consistently wherever an array would otherwise be converted to an overflow object.
    This also covers the `arrayLimit: 1` scalar-to-array boundary for plain duplicate keys,
    bracket arrays, and mixed index/key notation.
    ljharb committed Jun 23, 2026
    Configuration menu
    Copy the full SHA
    963e538 View commit details
    Browse the repository at this point in the history
  2. [Robustness] parse: throw the arrayLimit error before splitting o…

    …versized comma values
    
    With `comma` and `throwOnLimitExceeded`, a single large comma-separated value was fully split into an array before the `arrayLimit` check ran,
    so an oversized value allocated the whole array
    (and could exhaust memory)
    before the `RangeError` was thrown.
    Count commas up to the limit and throw before splitting,
    for flat (non-bracket) values.
    
    Bracket `[]=` comma groups are intentionally one nested element,
    so they are unaffected.
    The post-split comma throw is now redundant
    (`utils.combine` already throws when `throwOnLimitExceeded` is set)
    and is removed.
    ljharb committed Jun 23, 2026
    Configuration menu
    Copy the full SHA
    52afe00 View commit details
    Browse the repository at this point in the history
  3. [Perf] utils: make compact O(n) via a side-channel visited-set in…

    …stead of `Array.indexOf`
    
    `compact` tracked visited sub-objects in a plain array and tested membership with `refs.indexOf(val)` (O(n) per lookup),
    so the final graph walk was O(V^2) in the number of distinct sub-objects.
    Replace the array with a `side-channel` (already a dependency,
    already used in this file for `overflowChannel`) for O(1) membership, making the walk O(V).
    
    Membership semantics are identical, so circular-reference dedup is unchanged.
    `side-channel` is WeakMap-backed on modern engines and degrades gracefully on old ones,
    so this keeps `engines.node >= 0.6` (unlike a native `Set`/`WeakMap`).
    ljharb committed Jun 23, 2026
    Configuration menu
    Copy the full SHA
    5d5f723 View commit details
    Browse the repository at this point in the history
  4. [Tests] parse: characterize current lenient handling of unbalanced …

    …bracket keys (#558)
    
    Pin the current (lenient) parse output for every malformed/unbalanced bracket-key shape,
    so any future change to that behavior
    (e.g. the proposed "throw on unbalanced brackets" in #560)
    is explicit in the test diff rather than silent.
    
    Each case asserts both that parsing does not throw and the exact output,
    via a small `characterizeParse` helper, so a change that introduces a throw fails cleanly per case instead of aborting the run.
    
    Covers the cases #560 would make throw
    (`a[bc`, `a[`, `a[b][c`, `a[b]c[d`, the issue reproduction, stray-close variants),
    the ones it would leave as literals
    (inner-bracket and bracket-prefixed keys),
    the depth- and allowDots-dependent shapes,
    and the unaffected stray-close/trailing-text keys.
    ljharb committed Jun 23, 2026
    Configuration menu
    Copy the full SHA
    f4938f5 View commit details
    Browse the repository at this point in the history

Commits on Jun 24, 2026

  1. [Robustness] utils: enforce arrayLimit consistently across `merge…

    …`'s array paths
    
    `utils.merge` had two paths that grew an array past `arrayLimit` without the conversion/throw that `utils.combine` already performs:
    
     - the primitive-into-array branch was off by one (it tested the pre-append length with `> arrayLimit`, allowing `arrayLimit + 1` elements through)
     - the array-into-array branch did not consult `arrayLimit` at all
    
    Both now convert to an overflow object, or throw under `throwOnLimitExceeded`,
    once the resulting length exceeds `arrayLimit`,
    matching `combine` and the indexed and duplicate-bracket paths.
    So `a[0]=x&a[]=y` no longer stays a 2-element array at `arrayLimit: 1`.
    ljharb committed Jun 24, 2026
    Configuration menu
    Copy the full SHA
    74a0f6a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    adce539 View commit details
    Browse the repository at this point in the history
  3. [Deps] update side-channel

    ljharb committed Jun 24, 2026
    Configuration menu
    Copy the full SHA
    c38af42 View commit details
    Browse the repository at this point in the history
  4. v6.15.3

    ljharb committed Jun 24, 2026
    Configuration menu
    Copy the full SHA
    18d085e View commit details
    Browse the repository at this point in the history
Loading