Repository navigation
fix(messaging): split Telegram and Twitch messages on char boundaries - #662
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
This branch has not been deployed
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
split_messagein the Telegram and Twitch adapters slices replies at a fixed byte index (remaining[..max_len]).byte index N is not a char boundary, and the reply is never delivered.split_messagealready clamp to a char boundary (fix: prevent panic in split_message on multibyte UTF-8 char boundaries #49). The Telegram and Twitch copies did not get the same fix.Fix
Clamp the search window to the nearest char boundary at or before
max_lenwithstr::floor_char_boundary, the same helper used elsewhere in the codebase, before looking for a newline or space to split on.Testing
split_message_respects_multibyte_char_boundariesto the Telegram tests and a new test module in the Twitch adapter.byte index 5 is not a char boundary. After the fix, both pass.cargo fmt --all -- --checkandcargo clippy --lib --tests -- -Dwarningspass.Fixes #661