Skip to content

fix: use char-count truncation in parse_skill_metadata to prevent panic on multi-byte UTF-8#2

Open
nxxxsooo wants to merge 1 commit intoDargonLee:mainfrom
nxxxsooo:fix/utf8-parse-skill-metadata
Open

fix: use char-count truncation in parse_skill_metadata to prevent panic on multi-byte UTF-8#2
nxxxsooo wants to merge 1 commit intoDargonLee:mainfrom
nxxxsooo:fix/utf8-parse-skill-metadata

Conversation

@nxxxsooo
Copy link
Copy Markdown

Summary

  • Fix crash on launch caused by parse_skill_metadata panicking when truncating descriptions containing multi-byte UTF-8 characters (CJK, emoji, etc.)
  • Replace byte slicing (&desc[..197]) with chars().take(197) for safe, character-boundary-aware truncation

Root Cause

&desc[..197] is a byte-offset slice. When byte 197 lands inside a multi-byte character, Rust panics with slice_error_fail. This affects any user with SKILL.md files containing non-ASCII descriptions longer than ~67 CJK characters.

Testing

Built and tested on macOS 26.3.1 (aarch64) with ~90 skills containing Chinese/English mixed descriptions. App now launches without crashing.

Fixes #1

parse_skill_metadata used byte slicing (&desc[..197]) to truncate
long descriptions. This panics when byte 197 falls inside a
multi-byte UTF-8 character (e.g. CJK text).

Switch to chars().take(197) for safe, character-based truncation.

Fixes DargonLee#1
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.

Crash on launch: parse_skill_metadata panics on multi-byte UTF-8 characters

1 participant