From 6fa137a4ff84ba186b4bec106d88540e724ec40c Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Thu, 28 Feb 2019 21:39:38 +0000 Subject: [PATCH] Fix TxHashSet file filter for Windows. (#2641) (#2643) * Fix TxHashSet file filter for Windows. * rustfmt * Updating regexp * Adding in test case --- chain/src/txhashset/txhashset.rs | 4 ++-- util/src/zip.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/chain/src/txhashset/txhashset.rs b/chain/src/txhashset/txhashset.rs index 2bc816f96..6d547ee62 100644 --- a/chain/src/txhashset/txhashset.rs +++ b/chain/src/txhashset/txhashset.rs @@ -1486,7 +1486,7 @@ fn expected_file(path: &Path) -> bool { lazy_static! { static ref RE: Regex = Regex::new( format!( - r#"^({}|{}|{})(/pmmr_(hash|data|leaf|prun)\.bin(\.\w*)?)?$"#, + r#"^({}|{}|{})((/|\\)pmmr_(hash|data|leaf|prun)\.bin(\.\w*)?)?$"#, OUTPUT_SUBDIR, KERNEL_SUBDIR, RANGE_PROOF_SUBDIR ) .as_str() @@ -1648,7 +1648,7 @@ mod tests { assert!(!expected_file(Path::new("kernels"))); assert!(!expected_file(Path::new("xkernel"))); assert!(expected_file(Path::new("kernel"))); - assert!(expected_file(Path::new("kernel/pmmr_data.bin"))); + assert!(expected_file(Path::new("kernel\\pmmr_data.bin"))); assert!(expected_file(Path::new("kernel/pmmr_hash.bin"))); assert!(expected_file(Path::new("kernel/pmmr_leaf.bin"))); assert!(expected_file(Path::new("kernel/pmmr_prun.bin"))); diff --git a/util/src/zip.rs b/util/src/zip.rs index c79d0d008..94c36b8fe 100644 --- a/util/src/zip.rs +++ b/util/src/zip.rs @@ -73,8 +73,14 @@ where for i in 0..archive.len() { let mut file = archive.by_index(i)?; let san_name = file.sanitized_name(); - if san_name.to_str().unwrap_or("") != file.name() || !expected(&san_name) { - info!("ignoring a suspicious file: {}", file.name()); + if san_name.to_str().unwrap_or("").replace("\\", "/") != file.name().replace("\\", "/") + || !expected(&san_name) + { + info!( + "ignoring a suspicious file: {}, got {:?}", + file.name(), + san_name.to_str() + ); continue; } let file_path = dest.join(san_name);