Fix crash on multibyte char in page ranges #241 #242
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.
This fixes #241, which is a bug caused by incorrectly splitting the page ranges into groups.
The index calculation fails to account for a multibyte character at the end of a pages group. The subsequent split operation on the incorrect index leads to a crash, as described in the issue.
Examples:
Both page ranges are converted to a
321
followed by–
, which is an utf8 character with multiple bytesIn addition to the fix, I've added a few tests for this and removed the string window in favor of the chars iterator from the std.