Fix Unpaired Surrogate Encoding#157
Merged
Merged
Conversation
rvagg
approved these changes
Jan 19, 2026
rvagg
left a comment
Owner
There was a problem hiding this comment.
nice, thanks for chasing this down
github-actions Bot
pushed a commit
that referenced
this pull request
Jan 19, 2026
## [4.4.0](v4.3.2...v4.4.0) (2026-01-19) ### Features * **encode:** Allow ignoring `undefined` plain object properties ([a0db184](a0db184)), closes [#155](#155) * **token:** add Type.equals() for bundler-safe type comparison ([#159](#159)) ([b3e7cf4](b3e7cf4)), closes [#136](#136) ### Bug Fixes * **encode:** replace unpaired surrogates with U+FFFD in utf8ToBytes ([#157](#157)) ([362856c](362856c)) ### Trivial Changes * **ci:** OIDC publishing ([743ecc3](743ecc3)) * **deps-dev:** bump @types/node from 24.10.3 to 25.0.0 ([#153](#153)) ([20f9e4f](20f9e4f)) * **deps:** bump actions/setup-node from 6.1.0 to 6.2.0 ([#158](#158)) ([feafeb2](feafeb2)) * minor optimisation & test additions for ignoreUndefinedProperties ([55f653c](55f653c))
|
🎉 This PR is included in version 4.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #156
Adds new test cases for encode and decode of unpaired surrogates (Note: I've only run the tests in nodejs thus far).
Fixes
utf8ToBytes()behaviour to match that ofBuffer.from(string), i.e. to encode unmatched surrogates as U+FFFD, and thus the behaviour is now the same for strings <64 and >64 in length.I didn't make any changes to the decode behaviour because that seems good already (it performs U+FFFD substitution).