From: Elias Rohrer Date: Mon, 21 Aug 2023 12:58:34 +0000 (+0200) Subject: f Better handling of `relative_path` X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=dc249c0db450c920165ecf6c3a10e8cdf5e13caa;p=rust-lightning f Better handling of `relative_path` --- diff --git a/lightning-persister/src/fs_store.rs b/lightning-persister/src/fs_store.rs index 5ccc4d8c3..c29f0fb05 100644 --- a/lightning-persister/src/fs_store.rs +++ b/lightning-persister/src/fs_store.rs @@ -259,8 +259,11 @@ impl KVStore for FilesystemStore { } } - if let Ok(relative_path) = p.strip_prefix(&prefixed_dest) { - keys.push(relative_path.display().to_string()) + if let Some(relative_path) = p.strip_prefix(&prefixed_dest).ok() + .and_then(|p| p.to_str()) { + if relative_path.chars().all(|c| c.is_ascii() && !c.is_control()) { + keys.push(relative_path.to_string()) + } } }