Repository navigation
fix(ink): no panic on a character across byte 4096 of an SVG (#126) - #145
Merged
DWAA1660 merged 2 commits intoNov 12, 2026
Merged
Conversation
`svg::is_ink` looked at the first 4096 bytes with a plain slice, which panicked when a character crossed byte 4096. The page scan reads such a head from every SVG beside a page, so an ordinary picture with a long comment took the window down while its page opened (AlienTechSoftware#126). The head is now cut with `floor_char_boundary`. Fixes AlienTechSoftware#126 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Fixes #126.
notecraft_ink::svg::is_inktook&text[..text.len().min(4096)], which panics when a multibyte character crosses byte 4096.page::ink_filesruns it over the lossily-decoded first 4096 bytes of every SVG beside a page when the page opens. An ordinary picture with, say, anéin a long comment therefore crashed the window. With a lossy head, the string ends in a 3-byte U+FFFD that crosses the cut as well.The head is now
&text[..text.floor_char_boundary(4096)](str::floor_char_boundaryis stable well below the workspace'srust-version = 1.95). Detection still reads only the head, as before.How it was checked
svg::tests::a_character_across_byte_4096_is_not_split: the issue's SVG, a lossy 4096-byte head of it ending in U+FFFD, and a real ink file with long multibyte text after its tag (still detected)page::tests::a_character_across_the_head_of_an_svg_does_not_stop_the_page_opening: the issue's SVG beside a real page.ink_filesreturns nothing and the page loads.cargo test -p notecraft-ink -p notecraft-store: passcargo fmt --all -- --check,cargo clippy -p notecraft-ink -p notecraft-store --all-targets -- -D warnings: clean🤖 Generated with Claude Code