Skip to content

Commit

Permalink
Merge pull request #391 from MakotoE/master
Browse files Browse the repository at this point in the history
Fix panic in `find_words` due to string access outside of a character boundary
  • Loading branch information
mgeisler authored Jun 26, 2021
2 parents 607704a + 4c35069 commit 747d698
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,12 @@ mod tests {
);
}

#[test]
fn fill_unicode_boundary() {
// https://github.com/mgeisler/textwrap/issues/390
fill("\u{1b}!Ͽ", 10);
}

#[test]
#[cfg(not(feature = "smawk"))]
#[cfg(not(feature = "unicode-linebreak"))]
Expand Down
2 changes: 1 addition & 1 deletion src/word_separators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl WordSeparator for UnicodeBreakProperties {
let mut opportunities = unicode_linebreak::linebreaks(&stripped)
.filter(|(idx, _)| {
#[allow(clippy::match_like_matches_macro)]
match &line[..*idx].chars().next_back() {
match &stripped[..*idx].chars().next_back() {
// We suppress breaks at ‘-’ since we want to control
// this via the WordSplitter.
Some('-') => false,
Expand Down

0 comments on commit 747d698

Please sign in to comment.