Merge pull request #14 from lionkor/fix-modloading

fix mod loading
This commit is contained in:
Luuk van Oijen
2023-11-29 22:47:28 +01:00
committed by GitHub
2 changed files with 2 additions and 2 deletions

View File

@@ -12,7 +12,7 @@ pub fn ensure_path_exists(path: &PathBuf) -> anyhow::Result<()> {
/// Joins a parent folder and a sub-path, resolving the subpath beforehand to ensure that
/// the resulting path is still within the parent folder, regardless of ".." in the sub-path.
pub fn join_path_secure(parent: &Path, sub: &Path) -> anyhow::Result<PathBuf> {
Ok(parent.join(sub.canonicalize()?.as_path()))
Ok(parent.join(sub.file_name().unwrap_or("".as_ref())))
}
/// Converts a PathBuf into a String in a lossy way. This is generally the way we want to do it

View File

@@ -229,7 +229,7 @@ impl Client {
mod_name.remove(0); // Remove f
debug!("Client is requesting file {}", mod_name);
let client_resources = config.general.get_server_resource_folder()?;
let client_resources = config.general.get_client_resource_folder()?;
let mod_path = fs_util::join_path_secure(Path::new(&client_resources), Path::new(&mod_name))?;
if !mod_path.exists() || !mod_path.is_file() {