fix: static file path resolving
Diff
src/staticfile_middleware/staticfile.rs | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
@@ -64,8 +64,10 @@ impl Staticfile {
res
};
let path_resolved = PathBuf::from(helpers::adjust_canonicalization(path_resolved));
let base_path = if is_assets { &self.assets } else { &self.root };
let path_resolved = PathBuf::from(helpers::adjust_canonicalization(
path_resolved.canonicalize()?,
));
if !path_resolved.starts_with(&base_path) {
@@ -89,7 +91,10 @@ impl Handler for Staticfile {
let path_resolved = match self.resolve_path(&req.url.path()) {
Ok(file_path) => file_path,
Err(_) => return Ok(Response::with(status::NotFound)),
Err(e) => {
trace!("{}", e);
return Ok(Response::with(status::NotFound));
}
};