Skip to content

fix(rooms): use char-based truncation to prevent panic on multi-byte Unicode (#564) - #565

Merged
ajianaz merged 1 commit into
developfrom
fix/room-summary-unicode-panic
Jul 5, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/room-summary-unicode-panic

Conversation

@ajianaz

@ajianaz ajianaz commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #564 — uteke room summary panics on multi-byte Unicode characters.

Root Cause

room_summary() used byte-index slicing (&s[..97], &s[..117]) to truncate memory content. Rust strings are UTF-8, so multi-byte chars (≤, ≥, etc.) take 2-3 bytes. Slicing at a fixed byte index can land mid-character, causing index out of bounds panic at rooms.rs:479:48.

Fix

  • Replace s.len() → s.chars().count() for length checks
  • Replace &s[..N] → s.chars().take(N).collect() for safe truncation
  • Fixed 3 occurrences: top_memories, recent_decisions, pinned highlights

Verification

  • cargo check -p uteke-core ✅
  • cargo fmt --all -- --check ✅
  • cargo clippy -p uteke-core --all-targets -- -D warnings ✅
  • No remaining byte-index slicing patterns in rooms.rs

…Unicode

Fixes #564

room_summary() panicked on multi-byte Unicode chars (≤, ≥, etc.) in memory
content because it used byte-index slicing (&s[..97]) which can split
mid-character.

- Replace s.len() with s.chars().count() for length check
- Replace &s[..N] with s.chars().take(N).collect() for safe truncation
- Fix 3 occurrences: top_memories, recent_decisions, pinned highlights

Closes #564
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-cli · BYOK · MIT

@ajianaz
ajianaz merged commit 26a300f into develop Jul 5, 2026
8 checks passed
@ajianaz
ajianaz deleted the fix/room-summary-unicode-panic branch July 5, 2026 03:00
ajianaz added a commit that referenced this pull request Aug 13, 2026
fix(rooms): use char-based truncation to prevent panic on multi-byte Unicode (#564)
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.

bug: uteke room summary panics on multi-byte Unicode characters

1 participant