From dbd932bf4646fcc2308c64a406fddf8b81f8a74c Mon Sep 17 00:00:00 2001 From: dave Date: Wed, 25 Mar 2026 13:55:49 +0000 Subject: [PATCH] storkit: create 392_bug_strip_prefix_ci_panics_on_multi_byte_utf_8_characters --- ...i_panics_on_multi_byte_utf_8_characters.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .storkit/work/1_backlog/392_bug_strip_prefix_ci_panics_on_multi_byte_utf_8_characters.md diff --git a/.storkit/work/1_backlog/392_bug_strip_prefix_ci_panics_on_multi_byte_utf_8_characters.md b/.storkit/work/1_backlog/392_bug_strip_prefix_ci_panics_on_multi_byte_utf_8_characters.md new file mode 100644 index 0000000..1072e95 --- /dev/null +++ b/.storkit/work/1_backlog/392_bug_strip_prefix_ci_panics_on_multi_byte_utf_8_characters.md @@ -0,0 +1,27 @@ +--- +name: "strip_prefix_ci panics on multi-byte UTF-8 characters" +--- + +# Bug 392: strip_prefix_ci panics on multi-byte UTF-8 characters + +## Description + +strip_prefix_ci in matrix/commands/mod.rs panics when slicing text at a byte offset that falls inside a multi-byte UTF-8 character (e.g. right single quote ' is 3 bytes). This affects all transports (WhatsApp, Slack, Matrix) since they all share try_handle_command → strip_bot_mention → strip_prefix_ci. The panic occurs at line 234: text[..prefix.len()] when prefix.len() is not a char boundary in the input text. + +## How to Reproduce + +1. Send a message to the WhatsApp bot containing multi-byte UTF-8 characters (e.g. right single quotes or emojis) where the bot name prefix length lands inside a multi-byte character\n2. Example: "For now let's just deal with it" where the ' (right single quote, bytes 11..14) gets sliced at byte 12 + +## Actual Result + +Thread panics: byte index 12 is not a char boundary; it is inside ''' (bytes 11..14) + +## Expected Result + +The function should handle multi-byte UTF-8 characters gracefully without panicking. If the prefix length doesn't fall on a char boundary, the text doesn't match the prefix — return None. + +## Acceptance Criteria + +- [ ] strip_prefix_ci checks text.is_char_boundary(prefix.len()) before slicing and returns None if not on a boundary +- [ ] Messages containing multi-byte UTF-8 characters (smart quotes, emojis, CJK, etc.) do not panic +- [ ] All transports (WhatsApp, Slack, Matrix) are covered since they share the same code path