---
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
