Skip to content

UTF-8 panic: String slicing at fixed byte offsets in 8+ locations #978

Closed

Description

@ajianaz

Problem

Multiple locations slice strings at fixed byte offsets without UTF-8 boundary checks:

File Line Code
lib.rs 1234 &m.content[..77]
lib.rs 1746 &chunk_snippet[..200]
room.rs 133 &m.content[..77]
edges.rs 40 string slicing
mod.rs 280 string slicing
orphans.rs 42 string slicing

All panic if byte offset lands inside a multi-byte UTF-8 character.

Fix

Create a helper: fn safe_truncate(s: &str, max_bytes: usize) -> &str that uses s.floor_char_boundary(n) or manual iteration.

Severity: MAJOR (crash on non-ASCII content)

Activity

  1. added
    bug
    scope:core
    on Aug 10, 2026
  2. ajianaz commented on Aug 10, 2026

    @ajianaz
    CollaboratorAuthor

    Fixed in #983 (merged to develop)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugscope:core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions