Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions certipy/lib/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ def try_to_save_file(
"""
logging.debug(f"Attempting to write data to {output_path!r}")

# Clean up the output path
output_path = output_path.replace("\\", "_").replace("/", "_").replace(":", "_")
# Clean up only the filename part, not the directory path
directory = os.path.dirname(output_path)
filename = os.path.basename(output_path)
# Sanitize only the filename to remove invalid characters
filename = filename.replace(":", "_")
output_path = os.path.join(directory, filename) if directory else filename

# Handle file existence check and overwrite confirmation
output_path = _handle_file_exists(output_path)
Expand Down