From a3d7c53863c9d00bff4e81eec65f1b436ef17866 Mon Sep 17 00:00:00 2001 From: Makoto Date: Fri, 25 Jun 2021 11:32:27 -0700 Subject: [PATCH 1/4] Fix find_words() --- src/lib.rs | 6 ++++++ src/word_separators.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 5a3f4b1b..452a266a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1850,6 +1850,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"))] diff --git a/src/word_separators.rs b/src/word_separators.rs index cb1b8a9c..db03a91f 100644 --- a/src/word_separators.rs +++ b/src/word_separators.rs @@ -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, From d50d76b7ec11410d21b543e1260e55c6dce47e9d Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Sat, 26 Jun 2021 21:22:21 +0000 Subject: [PATCH 2/4] Add dependency graph for version 0.14.1 --- images/textwrap-0.14.1.svg | 21 +++++++++++++++++++++ src/lib.rs | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 images/textwrap-0.14.1.svg diff --git a/images/textwrap-0.14.1.svg b/images/textwrap-0.14.1.svg new file mode 100644 index 00000000..bc234068 --- /dev/null +++ b/images/textwrap-0.14.1.svg @@ -0,0 +1,21 @@ + + + + +textwrap + +smawk + + + + + +unicode-linebreak + + + +unicode-width + + + + diff --git a/src/lib.rs b/src/lib.rs index 452a266a..b06c706d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -124,7 +124,7 @@ //! The full dependency graph, where dashed lines indicate optional //! dependencies, is shown below: //! -//! +//! //! //! ## Default Features //! From 0050703757ee835a8c6a5c9e87bb2910f5217c9f Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Sat, 26 Jun 2021 21:22:21 +0000 Subject: [PATCH 3/4] Update changelog for version 0.14.1 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 534072e4..f8ee1708 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ This file lists the most important changes made in each release of `textwrap`. +## Version 0.14.1 (2021-06-26) + +This release fixes a panic reported by @Makoto, thanks! + +* [#391](https://github.com/mgeisler/textwrap/pull/391): Fix panic in + `find_words` due to string access outside of a character boundary. + ## Version 0.14.0 (2021-06-05) This is a major feature release which makes Textwrap more configurable From 40f20bec021dc79ae7557b7db6d5ceb11446a1b6 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Sat, 26 Jun 2021 21:23:46 +0000 Subject: [PATCH 4/4] Bump version to 0.14.1 --- Cargo.toml | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7539b62f..152c856a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "textwrap" -version = "0.14.0" +version = "0.14.1" authors = ["Martin Geisler "] description = "Powerful library for word wrapping, indenting, and dedenting strings" documentation = "https://docs.rs/textwrap/" diff --git a/src/lib.rs b/src/lib.rs index b06c706d..ae014edf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -177,7 +177,7 @@ //! [terminal_size]: https://docs.rs/terminal_size/ //! [hyphenation]: https://docs.rs/hyphenation/ -#![doc(html_root_url = "https://docs.rs/textwrap/0.14.0")] +#![doc(html_root_url = "https://docs.rs/textwrap/0.14.1")] #![forbid(unsafe_code)] // See https://github.com/mgeisler/textwrap/issues/210 #![deny(missing_docs)] #![deny(missing_debug_implementations)]