Skip to content

fix: encode large negative numbers in stringify#93

Merged
anonrig merged 1 commit intoanonrig:mainfrom
deepview-autofix:deepview/67f0c3a049
Apr 19, 2026
Merged

fix: encode large negative numbers in stringify#93
anonrig merged 1 commit intoanonrig:mainfrom
deepview-autofix:deepview/67f0c3a049

Conversation

@deepview-autofix
Copy link
Copy Markdown
Contributor

Numbers with magnitude >= 1e21 are serialized by JavaScript in exponential notation (e.g. -1e+22). The previous check only compared value < 1e21, so negative numbers in this range skipped encodeString and left a raw '+' in the output, which query string parsers decode as a space and corrupt the round-trip. Use Math.abs to apply the threshold symmetrically for positive and negative values.

Numbers with magnitude >= 1e21 are serialized by JavaScript in
exponential notation (e.g. -1e+22). The previous check only compared
value < 1e21, so negative numbers in this range skipped encodeString
and left a raw '+' in the output, which query string parsers decode
as a space and corrupt the round-trip. Use Math.abs to apply the
threshold symmetrically for positive and negative values.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: DeepView Autofix <276251120+deepview-autofix@users.noreply.github.com>
Co-Authored-By: Nikita Skovoroda <chalkerx@gmail.com>
Signed-off-by: Nikita Skovoroda <chalkerx@gmail.com>
@ChALkeR
Copy link
Copy Markdown
Contributor

ChALkeR commented Apr 19, 2026

Prior to this fix:

> require('fast-querystring').stringify({x:-1e100})
'x=-1e+100'
> require('querystring').stringify({x:-1e100})
'x=-1e%2B100'

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.97%. Comparing base (9dcbaf2) to head (104c05d).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #93   +/-   ##
=======================================
  Coverage   68.97%   68.97%           
=======================================
  Files           7        7           
  Lines         448      448           
  Branches       72       72           
=======================================
  Hits          309      309           
  Misses        136      136           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@anonrig anonrig merged commit 9fe75ff into anonrig:main Apr 19, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants