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
5 changes: 4 additions & 1 deletion skyvern/forge/sdk/api/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ def get_number_of_files_in_directory(directory: Path, recursive: bool = False) -


def sanitize_filename(filename: str) -> str:
return "".join(c for c in filename if c.isalnum() or c in ["-", "_", ".", "%", " "])
# Create a set for O(1) membership checks instead of a list
allowed = {"-", "_", ".", "%", " "}
# Use a list comprehension for improved performance in string assembly
return "".join([c for c in filename if c.isalnum() or c in allowed])


def rename_file(file_path: str, new_file_name: str) -> str:
Expand Down