]> git.bitcoin.ninja Git - rust-lightning/commitdiff
f Better handling of `relative_path`
authorElias Rohrer <dev@tnull.de>
Mon, 21 Aug 2023 12:58:34 +0000 (14:58 +0200)
committerElias Rohrer <dev@tnull.de>
Wed, 23 Aug 2023 10:37:23 +0000 (12:37 +0200)
lightning-persister/src/fs_store.rs

index 5ccc4d8c35571cd03cf8497a810ef586e10e2d11..c29f0fb05f54a86d559005ccbacc79a4a659eb7a 100644 (file)
@@ -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())
+                                       }
                        }
                }