Skip to content

Use UTF-16 code-unit length (min 1) for tapback amrln - #43

Open
sosjalapeno wants to merge 1 commit into
OpenBubbles:masterfrom
sosjalapeno:fix/tapback-amrln-utf16
Open

sosjalapeno wants to merge 1 commit into
OpenBubbles:masterfrom
sosjalapeno:fix/tapback-amrln-utf16

Conversation

@sosjalapeno

Copy link
Copy Markdown

Summary

Fix RawReactMessage.amrln (associatedMessageRange.length) calculation for part-targeted tapbacks (react.to_part.is_some()):

  1. UTF-16 code units instead of UTF-8 bytes: Apple's NSRange / NSString lengths are measured in UTF-16 code units. Previously react.to_text.len() sent UTF-8 byte length, which overcounts non-ASCII text (e.g., accented characters, CJK, emoji).
  2. Minimum length of 1: When react.to_text is empty (e.g. reacting to an attachment-only part like an image/voice message, or when a caller does not pass to_text), amrln became 0. Native Apple Messages.app silently drops part-targeted tapbacks (p:<part>/<GUID>) with amrln: 0 (an attachment part has length 1 for U+FFFC).

Reactions with react.to_part.is_none() continue to use u64::MAX.

Testing

  • Verified end-to-end against native macOS Messages.app: part-targeted tapbacks on ASCII, non-ASCII/emoji, and empty-text/attachment messages now deliver and render properly instead of being silently dropped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant