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 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/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 5a3f4b1b..ae014edf 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 //! @@ -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)] @@ -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,