Skip to content

fix(encodeurl): replace consecutive unpaired surrogates - #34

Open
awais-ur-rehman wants to merge 1 commit into
pillarjs:masterfrom
awais-ur-rehman:feat/encode-consecutive-surrogates
Open

awais-ur-rehman wants to merge 1 commit into
pillarjs:masterfrom
awais-ur-rehman:feat/encode-consecutive-surrogates

Conversation

@awais-ur-rehman

Copy link
Copy Markdown

Summary

Consecutive unpaired UTF-16 surrogates can survive replacement and make encodeurl throw URIError, despite its documented safe encoding behavior. Match valid pairs first and replace each remaining surrogate separately, preserving valid Unicode pairs.

Breaking Changes

None.

Testing

  • npm run test-ci — 20 passing; 100% statement, branch, function, and line coverage.
  • Full test suite also passes on Node 18.20.8.
  • npm run lint
  • git diff --check
  • Exhaustively compared 97,656 strings of up to seven ASCII/high-surrogate/low-surrogate code units against encodeURI(input.toWellFormed()) on Node 24.13.0.
  • Reproduce manually with require('encodeurl')('\uD800\uD800\uD800'); it now returns three percent-encoded replacement characters.

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.

1 participant