Skip to content

Commit

Permalink
Fix TxHashSet file filter for Windows. (#2641)
Browse files Browse the repository at this point in the history
* Fix TxHashSet file filter for Windows.

* rustfmt

* Updating regexp

* Adding in test case
  • Loading branch information
DavidBurkett authored and yeastplume committed Feb 28, 2019
1 parent d73124c commit d0ade29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions chain/src/txhashset/txhashset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,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()
Expand Down Expand Up @@ -1625,7 +1625,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")));
Expand Down
10 changes: 8 additions & 2 deletions util/src/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d0ade29

Please sign in to comment.