From eef49678ce2d6ad7475e0f71baf22e4d33b12349 Mon Sep 17 00:00:00 2001 From: dave Date: Wed, 25 Mar 2026 13:54:13 +0000 Subject: [PATCH] storkit: create 391_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/391_bug_strip_prefix_ci_panics_on_multi_byte_utf_8_characters.md diff --git a/.storkit/work/1_backlog/391_bug_strip_prefix_ci_panics_on_multi_byte_utf_8_characters.md b/.storkit/work/1_backlog/391_bug_strip_prefix_ci_panics_on_multi_byte_utf_8_characters.md new file mode 100644 index 0000000..e5217d4 --- /dev/null +++ b/.storkit/work/1_backlog/391_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 391: strip_prefix_ci panics on multi-byte UTF-8 characters + +## Description + +strip_prefix_ci in commands/mod.rs slices text by byte offset using prefix.len(), which panics when the slice boundary falls inside a multi-byte UTF-8 character (e.g. right single quote U+2019, emojis). The function assumes ASCII-safe byte boundaries but real WhatsApp/Matrix messages contain Unicode. + +## How to Reproduce + +1. Send a message to the bot containing a smart quote or emoji within the first N bytes (where N = bot name length)\n2. e.g. "For now let\u2019s just deal with it" where the bot name prefix check slices at byte 12, inside the 3-byte \u2019 character + +## Actual Result + +Thread panics: "byte index 12 is not a char boundary; it is inside \u2018\u2019\u2019 (bytes 11..14)" + +## Expected Result + +The function should safely handle multi-byte UTF-8 without panicking. If the slice boundary isn't a char boundary, the prefix doesn't match — return None. + +## Acceptance Criteria + +- [ ] strip_prefix_ci does not panic on messages containing multi-byte UTF-8 characters (smart quotes, emojis, CJK, etc.) +- [ ] Use text.get(..prefix.len()) or text.is_char_boundary() instead of direct indexing +- [ ] Add test cases for messages with emojis and smart quotes