AnonymousSpottedToad/securityPatternsRecovery / codebase /repos /python /DeepselSystems_deepsel /deepsel /utils /filename.py
| import os | |
| import random | |
| import string | |
| def sanitize_filename(filename): | |
| if not filename: | |
| return "" | |
| special_chars = "~!@#$%^&*()" | |
| sanitized = "".join(char for char in filename if char not in special_chars) | |
| return sanitized | |
| def randomize_file_name(filename, length: int = 10): | |
| characters = string.ascii_letters + string.digits | |
| file_ext = os.path.splitext(filename)[1] | |
| file_name_part = os.path.splitext(filename)[0] | |
| random_string = "".join( | |
| random.choice(characters) for _ in range(length) # nosec B311 | |
| ) | |
| new_filename = f"{file_name_part}-{random_string}{file_ext}" | |
| return new_filename | |
Xet Storage Details
- Size:
- 648 Bytes
- Xet hash:
- cfcb134b7e2a191e0b15d8f403a599cb85719aeb5273f0b1f9bf959f1d4fcdee
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.