Skip to content

Commit 1cf1774

Browse files
Clean expanded paths
This better mimics the behaviour of std::fs::canonicalize without evaluating symlinks.
1 parent 84e772e commit 1cf1774

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ hex = "0.4.3"
1818
ketos = "0.12"
1919
ketos_derive = "0.12"
2020
libc = "0.2.48"
21+
path-clean = "1.0.1"
2122
regex = "1.11.0"
2223
serde = "1.0.210"
2324
serde_derive = "1.0.210"

src/lang.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::{
44
};
55
use ketos::{Context, Error, FromValueRef, Name, Value};
66
use ketos_derive::{ForeignValue, FromValueRef};
7+
use path_clean::PathClean;
78
use std::{
89
cell::{Ref, RefCell},
910
env,
@@ -76,7 +77,7 @@ fn path_concat(vals: &mut [Value]) -> Result<String, Error> {
7677
|acc, v| acc.join(<&str as FromValueRef>::from_value_ref(v).unwrap()), // TODO(burke): don't unwrap
7778
);
7879

79-
Ok(res.to_string_lossy().to_string())
80+
Ok(res.clean().to_string_lossy().to_string())
8081
}
8182

8283
impl ShadowLang {
@@ -250,8 +251,9 @@ impl ShadowLang {
250251
}));
251252
}
252253
};
254+
let cleaned = absolutized.clean();
253255
Ok(<String as Into<Value>>::into(
254-
absolutized.to_string_lossy().to_string(),
256+
cleaned.to_string_lossy().to_string(),
255257
))
256258
})
257259
});

0 commit comments

Comments
 (0)