Repository navigation
fix(sanitize): keep the joiners that hold emoji and words together - #349
Merged
Merged
Conversation
sanitize_user_content stripped every U+200D and U+200C, so list_messages, names and titles returned 👨👩👧👦 instead of 👨👩👧👦, 🏳️🌈 for the pride flag, and Persian/Hindi words without their joiners. Keep a ZWJ between two emoji parts and a ZWJ/ZWNJ between two letters of a joining script (Arabic and Indic blocks). Joiners anywhere else, such as between Latin letters or at the edges, are still stripped, as are all other invisible characters. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018Xun6C4mXUAKbVSmiEEh79
chigwell
approved these changes
Oct 21, 2026
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.
Summary
The invisible-character stripping in
sanitize_user_contentremoves U+200C (ZWNJ) and U+200D (ZWJ) unconditionally (outsidepreserve_emoji), which mangles two legitimate uses:The strip pass now keeps a ZWJ only when both neighbours are emoji parts (So symbols, VS16, skin-tone modifiers) and a ZWNJ only when both neighbours are letters of a ZWNJ-using script; everywhere else — e.g. between Latin letters, where a joiner can split a word to hide it — they are stripped as before. The separate
_INVISIBLE_CHARSsubstitution is folded into the same single pass. Withpreserve_emoji, ZWJ retention is unchanged.Testing
tests/test_sanitize.pycovers composite emoji, Persian ZWNJ spelling, and the hostile case (joiners inside Latin words still stripped).🤖 Generated with Claude Code