Repository navigation
fix: keep surrogate pairs whole when truncating file names - #148
Merged
jerelvelarde merged 2 commits intoOct 6, 2026
Merged
jerelvelarde merged 2 commits into
jerelvelarde merged 2 commits into
Conversation
sanitizeFileName joined code points and then sliced the UTF-16 string, so a non-BMP character straddling the 180-character boundary was split into a lone surrogate that corrupted the stored display name. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jerelvelarde
approved these changes
Oct 6, 2026
jerelvelarde
left a comment
Collaborator
There was a problem hiding this comment.
Value: filename truncation keeps boundary surrogate pairs whole. Four resource-ID regressions passed. Template states problem and verification; no live providers involved. Names remain bounded and filesystem paths use UUIDs. Existing isolated-surrogate input is outside this fix. Updated-main diff reviewed; no actionable security finding. Merge after required CI.
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.
Problem
sanitizeFileNamefiltered code points, joined them, and then sliced the UTF-16 string at 180 units. A non-BMP character (emoji) straddling that boundary was split into a lone surrogate: the stored display name was corrupted and did not survive a UTF-8 round trip (the isolated half becomes U+FFFD).Fix
Slice the code-point array before joining, so the 180-character bound never lands inside a surrogate pair.
Verification
tests/resource-ids.test.ts: a name whose 180th code point is an emoji is kept whole, and a name truncated at the boundary has no split pair (code-point count asserted).Co-authored-by: Claude noreply@anthropic.com