Skip to content

fix: handle Unicode safely in XLSX text view - #10

Merged
RainLib merged 1 commit into
mainfrom
agent/fix-xlsx-unicode-truncation
Jul 20, 2026
Merged

fix: handle Unicode safely in XLSX text view#10
RainLib merged 1 commit into
mainfrom
agent/fix-xlsx-unicode-truncation

Conversation

@RainLib

@RainLib RainLib commented Jul 20, 2026

Copy link
Copy Markdown
Owner

What changed

  • Count XLSX cell widths by Unicode characters instead of UTF-8 bytes.
  • Truncate long cell values through chars() without slicing through a code point.
  • Add regression tests for Chinese text and zero/one-character widths.

Root cause

The text-grid renderer used String::len() and byte-range slicing. When the truncation boundary landed inside a multibyte character, Rust panicked with is not a char boundary.

Impact

officecli view <file.xlsx> --mode text now safely renders and truncates CJK and other multibyte text.

Validation

  • Real XLSX with a long Chinese cell rendered successfully without panic.
  • cargo test -p xlsx-handler --offline (25/25 passed)
  • cargo clippy --all-targets --offline -- -D warnings
  • cargo test --workspace --offline (including 54 CLI smoke tests)

Fixes #4

@RainLib
RainLib force-pushed the agent/fix-xlsx-unicode-truncation branch from fa8f4e7 to 888b948 Compare July 20, 2026 08:05
@RainLib
RainLib marked this pull request as ready for review July 20, 2026 08:09
@RainLib
RainLib merged commit 2abe7c8 into main Jul 20, 2026
3 checks passed
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:.xlsx文件读取失败

1 participant