mirror of
https://github.com/HKUDS/LightRAG.git
synced 2025-06-26 22:00:19 +00:00
Fix linting
This commit is contained in:
parent
60777d535b
commit
a506753548
@ -81,18 +81,20 @@ def sanitize_filename(filename: str, input_dir: Path) -> str:
|
||||
raise HTTPException(status_code=400, detail="Filename cannot be empty")
|
||||
|
||||
# Remove path separators and traversal sequences
|
||||
clean_name = filename.replace('/', '').replace('\\', '')
|
||||
clean_name = clean_name.replace('..', '')
|
||||
clean_name = filename.replace("/", "").replace("\\", "")
|
||||
clean_name = clean_name.replace("..", "")
|
||||
|
||||
# Remove control characters and null bytes
|
||||
clean_name = ''.join(c for c in clean_name if ord(c) >= 32 and c != '\x7f')
|
||||
clean_name = "".join(c for c in clean_name if ord(c) >= 32 and c != "\x7f")
|
||||
|
||||
# Remove leading/trailing whitespace and dots
|
||||
clean_name = clean_name.strip().strip('.')
|
||||
clean_name = clean_name.strip().strip(".")
|
||||
|
||||
# Check if anything is left after sanitization
|
||||
if not clean_name:
|
||||
raise HTTPException(status_code=400, detail="Invalid filename after sanitization")
|
||||
raise HTTPException(
|
||||
status_code=400, detail="Invalid filename after sanitization"
|
||||
)
|
||||
|
||||
# Verify the final path stays within the input directory
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user