Skip to content

Commit

Permalink
feat(main): windows filepath sanitization
Browse files Browse the repository at this point in the history
Signed-off-by: Christina Sørensen <[email protected]>
  • Loading branch information
cafkafk committed Sep 22, 2023
1 parent f8153c0 commit 5d7749c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,12 @@ fn main() -> std::io::Result<()> {
.nth(1)
.unwrap_or("")
.trim_end_matches('\"')
.replace([' ', '/'], "_"); // This is to handle the "tests/itest" in ARGS
.replace([' ', '/'], "_") // This is to handle the "tests/itest" in ARGS
.replace(&['<', '>', ':', '"', '/', '\\', '|', '?', '*'][..], "_"); // Sanitize for Windows

let file_path = dump_path.join(format!("ptest_{}.toml", args));
let mut file = File::create(file_path).expect("Failed to create file");
let mut file =
File::create(&file_path).expect(&format!("Failed to create file at {:?}", file_path));
file.write_all(content.as_bytes())
.expect("Failed to write to file");
}
Expand Down

0 comments on commit 5d7749c

Please sign in to comment.