From 41376b9dd3018c19b3e42f4b70c1df2328844588 Mon Sep 17 00:00:00 2001 From: figsoda Date: Mon, 30 Jan 2023 23:58:04 -0500 Subject: [PATCH 1/4] unpin zstd-sys --- Cargo.lock | 1 - Cargo.toml | 3 --- 2 files changed, 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a408cb7..4394a57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -714,7 +714,6 @@ dependencies = [ "xz2", "zip", "zstd", - "zstd-sys", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 6723e19..22b92c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,9 +33,6 @@ ubyte = { version = "0.10.3", default-features = false } xz2 = "0.1.7" zip = { version = "0.6.3", default-features = false, features = ["time"] } zstd = { version = "0.12.2", default-features = false } -# zstd-sys > 2.0.1 unconditionally enables thin LTO and causes CI to fail -# https://github.com/gyscos/zstd-rs/pull/155 -zstd-sys = "=2.0.1" [target.'cfg(unix)'.dependencies] time = { version = "0.3.17", default-features = false } From 2238a20f0f25c96b07d52c369d545bf2975f0533 Mon Sep 17 00:00:00 2001 From: figsoda Date: Tue, 31 Jan 2023 10:57:07 -0500 Subject: [PATCH 2/4] fix handling of unknown extensions --- src/extension.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/extension.rs b/src/extension.rs index a4166af..46b27dd 100644 --- a/src/extension.rs +++ b/src/extension.rs @@ -113,11 +113,12 @@ fn to_extension(ext: &[u8]) -> Option { )) } -fn split_extension<'a>(name: &mut &'a [u8]) -> Option<&'a [u8]> { +fn split_extension(name: &mut &[u8]) -> Option { let (new_name, ext) = name.rsplit_once_str(b".")?; if matches!(new_name, b"" | b"." | b"..") { return None; } + let ext = to_extension(ext)?; *name = new_name; Some(ext) } @@ -149,7 +150,7 @@ pub fn separate_known_extensions_from_name(path: &Path) -> (&Path, Vec Date: Tue, 31 Jan 2023 11:00:28 -0500 Subject: [PATCH 3/4] add changelog entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e058e61..165fcb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,10 @@ Categories Used: - Multi-threaded compression for gzip and snappy using gzp [\#348](https://github.com/ouch-org/ouch/pull/348) ([figsoda](https://github.com/figsoda)) +### Bug fixes + +- Fix handling of unknown extensions during decompression [\#355](https://github.com/ouch-org/ouch/pull/355) ([figsoda](https://github.com/figsoda)) + ## [0.4.1](https://github.com/ouch-org/ouch/compare/0.4.0...0.4.1) ### New Features From fe464213b3ebbf07c332fd8ae16d3adee4a03e40 Mon Sep 17 00:00:00 2001 From: figsoda Date: Tue, 31 Jan 2023 14:21:19 -0500 Subject: [PATCH 4/4] fix typos --- CHANGELOG.md | 6 +++--- src/commands/mod.rs | 2 +- src/error.rs | 4 ++-- src/macros.rs | 4 ++-- tests/utils.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e058e61..703c766 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,7 +99,7 @@ Categories Used: - Optimize `strip_cur_dir` [\#167](https://github.com/ouch-org/ouch/pull/167) ([vrmiguel](https://github.com/vrmiguel)) - Improve zip errors when paths are not utf8 valid [\#181](https://github.com/ouch-org/ouch/pull/181) ([marcospb19](https://github.com/marcospb19)) - Simplify/optimize several file inferring functions [\#204](https://github.com/ouch-org/ouch/pull/204) ([vrmiguel](https://github.com/vrmiguel)) -- List command: print file immediatly after it is processed [\#225](https://github.com/ouch-org/ouch/pull/225) ([sigmaSd](https://github.com/sigmaSd)) +- List command: print file immediately after it is processed [\#225](https://github.com/ouch-org/ouch/pull/225) ([sigmaSd](https://github.com/sigmaSd)) - Use `Cow<'static, str>` in `FinalError` [\#246](https://github.com/ouch-org/ouch/pull/246) ([vrmiguel](https://github.com/vrmiguel)) - Don't allocate when possible in `to_utf`, `nice_directory_display` [\#249](https://github.com/ouch-org/ouch/pull/249) ([vrmiguel](https://github.com/vrmiguel)) - Allow overriding the completions output directory [\#251]](https://github.com/ouch-org/ouch/pull/251) ([jcgruenhage](https://github.com/jcgruenhage)) @@ -174,14 +174,14 @@ Categories Used: - Empty folders are ignored in archive compression formats [\#41](https://github.com/ouch-org/ouch/issues/41) ([GabrielSimonetto](https://github.com/GabrielSimonetto)) - fix macOS executable paths [\#69](https://github.com/ouch-org/ouch/pull/69) ([vrmiguel](https://github.com/vrmiguel)) -- Print the format type when the format is in an incorrent position [\#84](https://github.com/ouch-org/ouch/pull/84) ([dcariotti](https://github.com/dcariotti)) +- Print the format type when the format is in an incorrect position [\#84](https://github.com/ouch-org/ouch/pull/84) ([dcariotti](https://github.com/dcariotti)) - Compressing a single file to a single format that's not `tar` or `zip` panics [\#87](https://github.com/ouch-org/ouch/issues/87) & [\#89](https://github.com/ouch-org/ouch/pull/89) ([marcospb19](https://github.com/marcospb19)) - Compression flag `--output` not working with single file compression [\#90](https://github.com/ouch-org/ouch/issues/90) & [\#93](https://github.com/ouch-org/ouch/pull/93) ([figsoda](https://github.com/figsoda)) - Fix NO_COLOR issues, remove some dead code [\#66](https://github.com/ouch-org/ouch/issues/66), [\#62](https://github.com/ouch-org/ouch/issues/62), & [\#95](https://github.com/ouch-org/ouch/pull/95) ([figsoda](https://github.com/figsoda)) - Add proper error message when using conflicting flags \(e.g. `--yes --no`\) [\#55](https://github.com/ouch-org/ouch/issues/55) & [\#99](https://github.com/ouch-org/ouch/pull/99) ([SpyrosRoum](https://github.com/SpyrosRoum)) - Fix wrong archive format detection patterns [\#125](https://github.com/ouch-org/ouch/pull/125) ([SpyrosRoum](https://github.com/SpyrosRoum)) - Decompressing file without extension gives bad error message [\#137](https://github.com/ouch-org/ouch/issues/137) ([marcospb19](https://github.com/marcospb19)) -- Fix decompression overwritting files without asking and failing on directories [\#141](https://github.com/ouch-org/ouch/pull/141) ([SpyrosRoum](https://github.com/SpyrosRoum)) +- Fix decompression overwriting files without asking and failing on directories [\#141](https://github.com/ouch-org/ouch/pull/141) ([SpyrosRoum](https://github.com/SpyrosRoum)) ### Improvements diff --git a/src/commands/mod.rs b/src/commands/mod.rs index e2c6954..95f8cfc 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -366,7 +366,7 @@ fn check_mime_type( // File with no extension // Try to detect it automatically and prompt the user about it if let Some(detected_format) = try_infer_extension(path) { - // Infering the file extension can have unpredicted consequences (e.g. the user just + // Inferring the file extension can have unpredicted consequences (e.g. the user just // mistyped, ...) which we should always inform the user about. info!( accessible, diff --git a/src/error.rs b/src/error.rs index 8771e68..138fef8 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,6 +1,6 @@ //! Error types definitions. //! -//! All usage errors will pass throught the Error enum, a lot of them in the Error::Custom. +//! All usage errors will pass through the Error enum, a lot of them in the Error::Custom. use std::{ borrow::Cow, @@ -73,7 +73,7 @@ impl Display for FinalError { if !self.hints.is_empty() { // Separate by one blank line. writeln!(f)?; - // to reduce redundant output for text-to-speach systems, braille + // to reduce redundant output for text-to-speech systems, braille // displays and so on, only print "hints" once in ACCESSIBLE mode if is_running_in_accessible_mode() { write!(f, "\n{}hints:{}", *GREEN, *RESET)?; diff --git a/src/macros.rs b/src/macros.rs index 338ece7..8b3f5f6 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -5,14 +5,14 @@ /// There are essentially two different versions of the `info!()` macro: /// - `info!(accessible, ...)` should only be used for short, important /// information which is expected to be useful for e.g. blind users whose -/// text-to-speach systems read out every output line, which is why we +/// text-to-speech systems read out every output line, which is why we /// should reduce nonessential output to a minimum when running in /// ACCESSIBLE mode /// - `info!(inaccessible, ...)` can be used more carelessly / for less /// important information. A seeing user can easily skim through more lines /// of output, so e.g. reporting every single processed file can be helpful, /// while it would generate long and hard to navigate text for blind people -/// who have to have each line of output read to them aloud, whithout to +/// who have to have each line of output read to them aloud, without to /// ability to skip some lines deemed not important like a seeing person would. #[macro_export] macro_rules! info { diff --git a/tests/utils.rs b/tests/utils.rs index b69ae0a..d1af39a 100644 --- a/tests/utils.rs +++ b/tests/utils.rs @@ -80,7 +80,7 @@ pub fn assert_same_directory(x: impl Into, y: impl Into, prese (x, y) => { panic!( - "directories don't have the same number of entires\n left: `{:?}`,\n right: `{:?}`", + "directories don't have the same number of entries\n left: `{:?}`,\n right: `{:?}`", x.map(|x| x.path()), y.map(|y| y.path()), )