Repository navigation
Cut peer display names on code points, not UTF-16 units - #2695
Merged
Merged
Conversation
cleanText, safeName, grantPersonView and the other peer-string caps now cut with cutCodePoints, so a name whose bound falls inside an emoji is no longer stored as a lone high surrogate that every later UTF-8 write reads as U+FFFD. Values already stored that way are left unchanged, not migrated. Fixes #2693
Collaborator
Author
|
Verdict: PASS at d626b7b Ran at this tip: What I checked:
|
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.
Written-by: Dev
Fixes #2693
Owner: Dev
Reviewer: Reviewer
What changed
A friend's Bot or owner display name is capped at 60 characters, and the cap now counts code points, not UTF-16 units. On
main,'a'.repeat(59) + U+1F600 + 'b'throughcleanTextkept'a'.repeat(59)plus a lone high surrogate —isWellFormed() === false,efbfbdin UTF-8,\ud83dafter a JSON round-trip — and that value is not transient: it is stored insettings.shareRequests, becomes a remote session name and goes into a cross-home payload, so it outlives the message that carried it. Now the same input ends as'a'.repeat(59) + U+1F600.cutCodePoints(#2581) was already the right helper. It moved toplugins/social/src/code-points.jssomcp-client.jscan share the one implementation, andsocial.jsre-exports it unchanged.Cut by code points now:
social.jscleanText(60),safeName(120),draftText(800)social.jspeer-text details: the onboardingbody.messagedetail (200),mapFaceAutoError's raw message (200),notePaused's reason (120), the send-failureshortline (100)social.jsuntrusted file preview (8000) and the invite message (280)mcp-client.jsgrantPersonView's person label (60)Checked and deliberately unchanged, because the cut is ASCII-only and cannot split a code point: the handle sanitizers (
social.js:88,mcp-client.js:225),slug(:270), the sha256 hex cuts (:271,:679,:822,:4783),homeHandleOf(:277),nextOnboardDisplayName's[^a-z0-9]+base (:305), and the SSE prefix probe (mcp-client.js:156).face-rooms.jskeeps its own documented copy of the helper (#2438) and is not touched here.Names already stored with a lone surrogate are not migrated; only new values stop being damaged, and the changelog fragment says so.
Verification at the tip
Tip SHA: d626b7b
Red first: with
plugins/social/src/social.jsandplugins/social/src/mcp-client.jsrestored to the livemainblobs and the new test kept, the new file gives 4 failures out of 5 (cleanText, safeName, grantPersonView, draftText; the "still caps, strips and falls back" case stays green because it does not cross a code-point bound).Ran at this tip:
Results: red 1/5 pass on the base blobs; at this tip 5/5 pass, the whole social suite is 614 tests with 0 failures, lint-plugins reports 0 errors (36 pre-existing warnings) and the packed
@flybot/socialimports, andchangelog.mjs checkfinds 32 well-formed fragments. No test line was relaxed, skipped or deleted.Not run (and why): full
npm run verify(the brief scoped the run to the social plugin);node scripts/ds-bot-patches.mjs checkandbuild-client.mjs --check(nothing undercore/changed);node core/scripts/check-arch-docs.mjs(it readsgit log base..HEADand this box has no git checkout —docs/subsystems/social.md, the page that ownsplugins/social/, is in this diff instead).Checkpoint
{ "pr": 2695, "claim": "Dev", "issue": 2693, "summary": "Peer display names, file names, drafts and error lines are now cut on code points instead of UTF-16 units, so a value whose bound falls inside an emoji no longer ends on a lone high surrogate that every later write reads as U+FFFD. The cutCodePoints helper (#2581) moved to src/code-points.js so mcp-client.js shares one implementation, and social.js re-exports it unchanged. Values already stored with a lone surrogate are left as they are, not migrated. A new test covers cleanText, safeName, draftText and grantPersonView, and it fails 4/5 when the fixed sources are reverted.", "files": [ "plugins/social/src/code-points.js", "plugins/social/src/social.js", "plugins/social/src/mcp-client.js", "plugins/social/test/name-code-points.test.js", "docs/subsystems/social.md", "changelog.d/2693-social-name-cut.fixed.md" ], "checks": { "ran": "plugins/social suite 614 pass; name-code-points 5/5; node scripts/lint-plugins.mjs social; node .github/scripts/changelog.mjs check", "result": "green", "at": "d626b7b557354d5a0154e114ea439ac787a993f1" }, "next": "none — ready for review" }