fix(imessage): strip U+FFFD garbage chars from echo text key normalization#2075
Open
BingqingLyu wants to merge 3 commits into
Open
fix(imessage): strip U+FFFD garbage chars from echo text key normalization#2075BingqingLyu wants to merge 3 commits into
BingqingLyu wants to merge 3 commits into
Conversation
…ation imsg extracts message text from the SQLite attributedBody column via NSAttributedString, which injects U+FFFD replacement characters and C0/C1 control characters around rich-text spans. The echo cache stores clean outbound text, but the reflected copy carries these garbage characters, defeating text-based deduplication. See: openclaw#61312, openclaw#61821. Fixes openclaw#61312, openclaw#61821
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
U+FFFD replacement characters and C0/C1 control characters injected by
imsgwhen extracting text fromNSAttributedString(attributedBodycolumn) break echo cache text-key matching, causing duplicate message delivery.The echo cache stores clean outbound text, but the reflected inbound copy carries garbage character prefixes —
normalizeEchoTextKey()only strips\r\n, so the keys never match and the echo slips through as a new inbound message.Fix: Strip
[\ufffd\ufffe\uffff\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]+before comparison innormalizeEchoTextKey().Previously included fixes (now upstream)
The original PR included two additional fixes that have since been merged independently by the OpenClaw team (openclaw#61619, openclaw#63868, openclaw#63980, openclaw#63989, openclaw#64000):
TTL 4s → 30s— shipped in 2026.4.10 (SENT_MESSAGE_TEXT_TTL_MS = 30e3)— shipped in 2026.4.10 withdestination_caller_idself-chat detectionisSelfChat+isAmbiguousSelfThreadThis PR now contains only the remaining unmerged fix.
Changes
extensions/imessage/src/monitor/echo-cache.ts: Strip U+FFFD/control chars innormalizeEchoTextKeyRelated Issues
Fixes openclaw#61312, openclaw#61821
Test Plan