Skip to content

Commit

Permalink
Use lexiclean crate for lexical path cleaning
Browse files Browse the repository at this point in the history
I moved all the lexical path cleaning functionality into a separate
crate, so it can be used by other projects.

type: reform
  • Loading branch information
casey committed Apr 22, 2020
1 parent 323434d commit 134c241
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 97 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog

UNRELEASED - 2020-04-22
-----------------------
- :zap: [`xxxxxxxxxxxx`](https://github.com/casey/intermodal/commits/master) Allow positional input to `imdl torrent verify` - Fixes [#375](https://github.com/casey/intermodal/issues/375) - _Casey Rodarmor <casey@rodarmor.com>_
- :art: [`xxxxxxxxxxxx`](https://github.com/casey/intermodal/commits/master) Use `lexiclean` crate for lexical path cleaning - _Casey Rodarmor <casey@rodarmor.com>_
- :zap: [`323434d0aa21`](https://github.com/casey/intermodal/commit/323434d0aa21ebfda5be85ecd4a38a55ed3fec0a) Allow positional input to `imdl torrent verify` - Fixes [#375](https://github.com/casey/intermodal/issues/375) - _Casey Rodarmor <casey@rodarmor.com>_
- :zap: [`5ba885dbc4f2`](https://github.com/casey/intermodal/commit/5ba885dbc4f24781d6a3240ddfc0c03177b12f1e) Take input to `imdl torrent create` as positional - Fixes [#375](https://github.com/casey/intermodal/issues/375) - _Casey Rodarmor <casey@rodarmor.com>_
- :wrench: [`c22df5a08326`](https://github.com/casey/intermodal/commit/c22df5a083265b03abd5531b1f5b2aad60aa68cd) Don't commit man pages - _Casey Rodarmor <casey@rodarmor.com>_
- :wrench: [`4d67d3a10d17`](https://github.com/casey/intermodal/commit/4d67d3a10d17db3c63af092a936eb5994ee107b1) Don't commit the book - _Casey Rodarmor <casey@rodarmor.com>_
Expand Down
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ atty = "0.2.0"
chrono = "0.4.1"
console = "0.10.0"
globset = "0.4.0"
ignore = "0.4.14"
lazy_static = "1.4.0"
lexiclean = "0.0.0"
libc = "0.2.0"
log = "0.4.8"
ignore = "0.4.14"
md5 = "0.7.0"
open = "1.4.0"
pretty_assertions = "0.6.0"
Expand Down
4 changes: 2 additions & 2 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub(crate) use chrono::{TimeZone, Utc};
pub(crate) use globset::{Glob, GlobMatcher};
pub(crate) use ignore::WalkBuilder;
pub(crate) use indicatif::{ProgressBar, ProgressStyle};
pub(crate) use lexiclean::Lexiclean;
pub(crate) use libc::EXIT_FAILURE;
pub(crate) use regex::{Regex, RegexSet};
pub(crate) use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer};
Expand Down Expand Up @@ -59,8 +60,7 @@ pub(crate) use crate::xor_args::xor_args;
// traits
pub(crate) use crate::{
input_stream::InputStream, into_u64::IntoU64, into_usize::IntoUsize, invariant::Invariant,
path_ext::PathExt, platform_interface::PlatformInterface, print::Print, reckoner::Reckoner,
step::Step,
platform_interface::PlatformInterface, print::Print, reckoner::Reckoner, step::Step,
};

// structs and enums
Expand Down
2 changes: 1 addition & 1 deletion src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl Env {
return Err(Error::internal("Empty path passed to resolve"));
}

Ok(self.dir().join(path).clean())
Ok(self.dir().join(path).lexiclean())
}

pub(crate) fn write(&mut self, path: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> Result<()> {
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ mod mode;
mod options;
mod output_stream;
mod output_target;
mod path_ext;
mod piece_length_picker;
mod piece_list;
mod platform;
Expand Down
89 changes: 0 additions & 89 deletions src/path_ext.rs

This file was deleted.

5 changes: 4 additions & 1 deletion src/subcommand/torrent/create/create_content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ impl CreateContent {
}

fn torrent_path(input: &Path, name: &str) -> PathBuf {
input.join("..").clean().join(format!("{}.torrent", name))
input
.join("..")
.lexiclean()
.join(format!("{}.torrent", name))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/torrent/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Verify {
content.clone()
} else {
match target {
InputTarget::Path(path) => path.join("..").join(&metainfo.info.name).clean(),
InputTarget::Path(path) => path.join("..").join(&metainfo.info.name).lexiclean(),
InputTarget::Stdin => PathBuf::from(&metainfo.info.name),
}
};
Expand Down

0 comments on commit 134c241

Please sign in to comment.