tor-config: Update to shellexpand 3.x

This is the new upstream version (published by me, recently).
It has the same MSRV and one breaking change:

The caller who specifies a home dir function for substituting into
strings, must now supply a string, not Path.  Previously shellexpand
would allow the caller to supply non-unicode data, and then simply not
substitute it.  That was an infelicity in the shellexpand API.

Now this infelicity is pushed into our code.  The overall behaviour of
Arti hasn't changed as a result.  And it seems reasonable to me.

shellexpand 3.x also has a module for expanding Paths instead, in
response to requests for this filed as upstream tickets.  We *could*
use that but I am not sanguine about that approach: the Pathness would
spread throughout much of our config and file handling code.

I think we should at the very least postpone trying to work with
invalid-unicode-paths as long as we can.
This commit is contained in:
Ian Jackson 2022-12-06 15:11:39 +00:00
parent 010ffd6ea6
commit ba338bdf37
3 changed files with 8 additions and 4 deletions

4
Cargo.lock generated
View File

@ -3095,9 +3095,9 @@ dependencies = [
[[package]]
name = "shellexpand"
version = "2.1.2"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ccc8076840c4da029af4f87e4e8daeb0fca6b87bbb02e10cb60b791450e11e4"
checksum = "dd1c7ddea665294d484c39fd0c0d2b7e35bbfe10035c5fe1854741a57f6880e1"
dependencies = [
"dirs",
]

View File

@ -28,7 +28,7 @@ paste = "1"
regex = { version = "1", default-features = false, features = ["std"] }
serde = { version = "1.0.103", features = ["derive"] }
serde_ignored = "0.1.3"
shellexpand = { version = "2.1.2", optional = true }
shellexpand = { version = "3.0", optional = true }
strum = { version = "0.24", features = ["derive"] }
thiserror = "1"
toml = "0.5.6"

View File

@ -171,10 +171,14 @@ fn expand(s: &str) -> Result<PathBuf, CfgPathError> {
/// Shellexpand helper: return the user's home directory if we can.
#[cfg(feature = "expand-paths")]
fn get_home() -> Option<&'static Path> {
fn get_home() -> Option<&'static str> {
base_dirs()
.ok()
.map(BaseDirs::home_dir)
// If user's home directory contains invalid unicode, fail to substitute it.
// This isn't great, but the alternative is to do *everything* with Path rather
// than String and that's a total pain.
.and_then(Path::to_str)
}
/// Shellexpand helper: return the directory holding the the currently executing program.